Hello, this is my first time posting here so im sorry for doing anything wrong. Also I am kinda new at programming so bare with me.

I am currently working on a function that basically reads a list of double values and assigns them to an array. But I ran across this problem that I have no idea what to do about. I've searched everywhere but seems like no one really had this problem, so I must be doing something completely wrong.

Here is the code I am working with:

```
void Employee::readSalary(Employee emp[])
{
int i = 0;
double thisSalary;
ifstream empFile;
empFile.open("salary.txt");
while(!empFile.eof())
{
empFile >> thisSalary; //reads in the double value
emp[i].setSalary(thisSalary); //assigns to the array
cout << emp[i].getSalary() << endl; //for test purposes
i++;
}
empFile.close();
}
```

Now in salary.txt I have 3 double values such as:

5.5

7.5

9.5

When this code runs, it outputs:

5.5

7.5

9.5

9.5

I have no idea why it reads in the last value twice and assigns it to two different array elements. Maybe I am not reading the double value the correct way? or is there something I am missing about the eof() function. I get the same problem if I read an Int, but I have no problem with strings. Any kind of help is GREATLY appreciated, I've been stuck on this for a while now. Thanks in advance.

-Qas