humm... I actually don't know. I normally use line return instead of space, so, I simply do readline().
1) read() and decide if you want to include as part of the integer or not.
2) readblock() a length and split the string using the space character.
Both are not as efficient as your example though.
If you have the the authority to change the file format, using line return would make your problem a lot easier. Or actually it is best to use binary file as it will save tons of data size and makes reading the HDD much more effective.
Probably will need to wait for other suggestions from others.