I made a simple program that calculates price for items sold. And saves the information into a a file. I am trying to read from this file which contains a string and integers. What is a good way to read to the end of file? I am currently using EOF function but is not working correctly. It repeats the last two lines.
 void viewTransactions();
 void viewTransactions()
{
    string productName,;
    int quantity, totalPrice;
    ifstream infile;
    infile.open ("transactions.txt");
    while(!infile.eof())
    {
    getline(infile, productName);
    infile >> quantity;
    infile >> totalPrice;
    infile.ignore(100, '\n');
    cout << productName << endl;
    cout << quantity << endl;
    cout << totalPrice << endl;
    }
}
"transactions.txt" contains:
Product
1
5
Product
2
10
Product
3
15
Console Output File When Read:
Product
1
5
Product
2
10
Product
3
15
3
15
 
    