- // Read current line
- scan_line(ifile, sep, posID, &ID, posValue, &value);
+ eof = feof(ifile);
+ if (!eof)
+ {
+ // Is there anything left to read? (file may end with '\n')
+ curChar = fgetc(ifile);
+ if (!feof(ifile) && curChar != '\n')
+ {
+ // Yes: read current line
+ ungetc(curChar, ifile);
+ scan_line(ifile, sep, posID, &ID, posValue, &value);
+ }
+ else
+ eof = 1;
+ }