Read it line by line and if line does not start with space, read first value from it with sscanf for example.
What you are doing is really wrong since you are reading line (without using results) then you are reading three values from next line... then line again... mess