This function is supposed to open a .txt file like this:
1    4    5 
2    4    6
etc. (with tab between numbers)
and save each number in one variable
void Graph::readData(char* fname)
{
    //cout<<"1";
    int x,y,w;//assistant variables
    ifstream input;//stream for reading file
    input.open(fname,ios::in);
    if(!input)
    {
        cerr<<"Input file doesn't exist"<<endl;//error if file doens exist
    }
    else
    {
        cout<<"Input file opened"<<endl;
        cout<<"Reading Data from file..."<<endl;
        while(!input.eof())//till the end of file
        {
            input>>x>>y>>w;//reads the links-site
            cout<<"x: "<<x<<"y:"<<y<<"w: "<<w<<endl;
            insertLink(x,y,w);//inserts them
        }
        input.close();//closing file
    }
}
However, when I "cout" the results I get something like this:
x=1  y=  w=5
x=2  y=  w=6
without y!
Why could this happen?
PS: In addition, eof() becomes true after the file is finished (reads one extra line). How can I stop while iteration properly?
This is the file I'm trying to read from: http://www.speedyshare.com/tpvuD/input.txt
 
    