title: .eof() loop not working
body: <p>I'm trying to read in numbers from a file and putting them into an array.  Right now when I run the program it prints 8 numbers, then the line ends and prints the same 8 numbers.  It's in a never ending loop.  What am I doing wrong?</p>
  
  <pre><code>#include &lt;iostream&gt;                                                             
  #include &lt;fstream&gt;                                                              
  using namespace std;                                                            
  
  int main()                                                                      
  {                                                                               
    int num;                                                                      
    ifstream infile;                                                              
    infile.open("euler8Nums.txt");                                                
      infile &gt;&gt; num;//must attempt to read info prior to an eof() test            
      while(!infile.eof()){                                                       
        cout &lt;&lt; num &lt;&lt; endl;                                                      
        infile &gt;&gt; num;                                                            
      }                                                                           
      infile.close();                                                             
      return 0;                                                                   
  }  
  </code></pre>