Here is the code . 
It is giving the EXACT output as shown below means it is reading the file.
But it is also showing fails as you can see it means fin.fails() is true.
I want to know why this is true although i am successful in reading the file.
#include<fstream>
#include<iostream>
using namespace std;
int main()
{   ifstream fin;
    fin.open("pro.txt");
    char ch;
    int data;
    while(!fin.eof())//!(fin >> ch).eof()
    {
        fin.get(ch);
        cout<<ch;
        if(fin.fail()) {
            cout<<"fails";
        break;
        }
    }
    fin.clear();
    fin.seekg(0);
    int pos=(int)fin.tellg();
    cout<<"\n this is :"<<pos;
    fin.close();
    return 0;
}
Output is :
this is my name
fails
this is 0
Contents of pro.txt:
this is my name
Don't know why this is happening!
 
    