title: C++: File Processing: matching sequential files
body: <p>I have a small problem. I have three files, OldMaster, Transaction and NewMaster. If the account numbers match between OldMaster and Transaction, I update the balance and write it to NewMaster. If they don't match, I write the original account info from OldMaster to NewMaster and display an error. </p>
  
  <p>There are 4 accounts in file OldMaster and 4 account transactions in file Transactions. For some reason my program is not processing the fourth (last) account/transaction in each file and NewMaster is not receiving data.</p>
  
  <pre><code>int accountNumber
  int accountNum;
  string lastName;
  string firstName;
  float currentBalance;
  float dollarAmount;
  
  inOldMaster &gt;&gt; accountNumber &gt;&gt; firstName &gt;&gt; lastName &gt;&gt; currentBalance;
  inTransaction &gt;&gt; accountNum &gt;&gt; dollarAmount;
  
  while ( !inOldMaster.eof() &amp;&amp; !inTransaction.eof() )
  {
      if ( accountNumber == accountNum )
      {
          currentBalance += dollarAmount;
          outNewMaster &lt;&lt; accountNum &lt;&lt; " " &lt;&lt; firstName &lt;&lt; " " &lt;&lt; lastName &lt;&lt; " " 
                       &lt;&lt; currentBalance &lt;&lt; endl;
      } 
      else if (accountNumber != accountNum)
      {
          outNewMaster &lt;&lt; accountNumber &lt;&lt; " " &lt;&lt; firstName &lt;&lt; " " &lt;&lt; lastName &lt;&lt; " " 
              &lt;&lt; currentBalance &lt;&lt; endl;
          cout &lt;&lt; "Unmatched transaction record for account number: " &lt;&lt; accountNum 
              &lt;&lt; endl;
      }
  
      inOldMaster &gt;&gt; accountNumber &gt;&gt; firstName &gt;&gt; lastName &gt;&gt; currentBalance;
      inTransaction &gt;&gt; accountNum &gt;&gt; dollarAmount;
  }
  </code></pre>