void StudentArrayV4::add_from(istream &infile) {
    Student temp;
    string name;
    getline(infile, name, ':');
    temp.set_name(name);
    int id;
    infile >> id;
    temp.set_id(id);
    double score;
    while (infile >> score)
    {
        temp.add_exam_score(score);
    }
    add(temp);
    if (name != "")
    {
        infile.ignore();
        infile.clear();
    }
}
int StudentArrayV4::add_all_from( istream& infile ) {
    while (!infile.eof())
    {
        add_from(infile);
        number_of_students++;
    }
    return number_of_students;
}
I want to use the function add_all_from to add Students to the array but it gets in an infinite loop. I don't understand why eof() doesn't work in this case.
 
    