LISTING 7:

// open a file, read through it sequentially, updating each record.

  {
     int i;
     binaryfile x(64);  // file object
     ...
     x.fileopen (filename, Update);
     ...
     for (i = x.fileread (FirstRecord) ; i > 0 ;
          i = x.fileread (NextRecord)) {
     ...             // processing the record
     x.filewrite();  // rewrite the modified record
     ...
     }
     ...
  }    // object x goes out of scope and is 
       // automatically closed and destroyed

