I m reading data from a text file and then printing it. I am not sure what I am doing wrong but the program prints the last line that it reads twice.
void bank_account::viewHistory()
{
ifstream in_file("bank_transaction_history.txt" , ios::in);
if(!in_file)
{
cout<<"File error \n";
}
cout<<"Event"<<setw(15)<<"Amount"<<setw(15)<<"Date"<<setw(20)<<"Current Balance"<<endl;
string eve,dat;
double am,bal;
while(!in_file.eof())
{
in_file>>eve>>am>>dat>>bal; //reading data from file
cout<<eve<<setw(10)<<am<<setw(20)<<dat<<setw(10)<<bal<<endl;
}
in_file.close();
}