title: c++ EOF running one too many times?
body: <p>This is my first time using EOF and/or files, and I am having an issue where my code hangs, which I believe is because my EOF is looping one too many times.</p>
  
  <p>I am imputing from a file, and dynamically creating objects that way, and it hangs once the file is run through.</p>
  
  <pre><code>        while( !studentFile.eof() )
      {
          cout &lt;&lt; "38\n";
          Student * temp = new Student();
          (*temp).input( studentFile );
  
          (*sdb).insert( (*temp) );           
      }
  </code></pre>
  
  <p>This chunk of code is the code in question. The cout >> "38\n"; is the line number and the reason I believe it is hanging from looping one too many times.</p>
  
  <p>The file only contains 4 student's worth of data, yet 38 appears 5 times, which is the reason I believe it is looping one too many times; Once it gets the last bit of data, it doesn't seem to register that the file has ended, and loops in again, but there is no data to input so my code hangs.</p>
  
  <p>How do I fix this? Is my logic correct?</p>
  
  <p>Thank you.</p>