am trying to read characters from file but when I use end of file function it loops more than the number of character inside the file by 1 .. but I don't know why ?
#include <iostream>
#include <fstream>
int main()
{
    ifstream file;
    char ch1;
        file.open("c:\\Downloads\\test.txt" , ios::in);
    int i=0;
    while(!file.eof())
    {  i++;
        file>>ch1;
                    cout<<ch1<<endl;
          }
           cout <<i<<endl;
file.close();
return 0;
}
file contains
[]
output : [ ] ] 3
 
     
    