#include <iostream>
#include <fstream>
using namespace std;
int main() {
    ifstream infile;
    int age;
    infile.open("intestfile.txt");
        if(infile){
            while(!infile.eof()) {
                infile >> age;
                cout << age << endl;
            }
        } else {
            cout << "Error opening file." << endl;
        }
    infile.close();
}
I am expecting an output like; 10 20 30 40 50 (this list displayed vertically). Why am I getting 10 20 30 40 50 50 and yet the input file has 10 20 30 40 50 only. where is the duplicate 50 coming from?
 
     
    