My current code adds extra portion to the final result. I am reading a csv file and adding certain elements to variables. My end result always adds an extra element to the screen? What am i doing wrong?
Code:
int main()
{
    ifstream file("data.csv");
    //checks to see if file is valid
    if (!file.is_open())
    {
        cout << "Invalid file" << endl;
    }
    string name;
    string age;
    string college;
    while (file.good())
    {
        getline(file, name, ',');
        getline(file, age, ',');
        getline(file, college, '\n');
        cout << "Name: " << name << '\n';
        cout << "Age: " << age << endl;
        cout << "College: " << college << endl;
        cout << "------------------" << endl;
    }
    //closes the file and program terminates
    file.close();
    return 0;
}
 
    