So I am reading in data from a text file in to a vector using a while loop.
Originally I had the code set up this way :
iftream infile;
while(infile)  // or even if i do while(!infile.eof())
    {
        infile>>data;
        vector1.push_back(data); //adding data in to the vector
    }
- but this caused one small problem that it read in the last item in the text file twice for some reason.
but if I have the code set up this way everything works fine :
iftream infile;
while(infile>>data)
{
    vector1.push_back(data); //adding data in to the vector
}
Why does the first code reads in the last item twice?
 
    