.eof() loop not working
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.  Its in a never ending loop.  What am i doing wrong?

    #include <iostream>                                                             
    #include <fstream>                                                              
    using namespace std;                                                            
                                                                                    
    int main()                                                                      
    {                                                                               
      int num;                                                                      
      ifstream infile;                                                              
      infile.open("euler8Nums.txt");                                                
        infile >> num;//must attempt to read info prior to an eof() test            
        while(!infile.eof()){                                                       
          cout << num << endl;                                                      
          infile >> num;                                                            
        }                                                                           
        infile.close();                                                             
        return 0;                                                                   
    }  
.eof() loop not working
===

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.  Its in a never ending loop.  What am i doing wrong?

    #include <iostream>                                                             
    #include <fstream>                                                              
    using namespace std;                                                            
                                                                                    
    int main()                                                                      
    {                                                                               
      int num;                                                                      
      ifstream infile;                                                              
      infile.open("euler8Nums.txt");                                                
        infile >> num;//must attempt to read info prior to an eof() test            
        while(!infile.eof()){                                                       
          cout << num << endl;                                                      
          infile >> num;                                                            
        }                                                                           
        infile.close();                                                             
        return 0;                                                                   
    }  