why does this program giving one output even if the initial position is at the end?

why does this program giving output '1' even if the initial position is at the end?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  #include <iostream>
#include<fstream>
#include<string>
using namespace std;

int main()
{
    ifstream Input_file;
    string items;
    int counter=0;
    Input_file.open("d:/new_file.txt",ios::ate);
    if(Input_file.fail())
    {
        cerr<<"The file open failed";
        exit(1);
    }
    while(!Input_file.eof())
    {
        Input_file>>items;
        counter++;
    }
    cout<<counter<<" items found!!!"<<endl;
    Input_file.close();
    return 0;
}
Topic archived. No new replies allowed.