displaying file the same way it was made?

If I create a file that looks like this for example,
car 2 4 6 8
truck 1 2 3 4 5 6
plane 4 5 6 7 9

Whenever I go to open it back up like this,
ifstream inputFile;
string line;

inputFile.open("file.txt");
while (inputFile>>line)
{
cout << line << endl;
}
inputFile.close();
return 0;
}

It displays output like this,
car
2
4
6
8

How can I get it to display like above?
1
2
while( std::getline(inputFile, line) )
//... 
Thanks! That worked
Topic archived. No new replies allowed.