EOF isn't a good test for end of file, unfortunately. If the last line has a newline on it, you can wind up having repeat values for the last input.

fscanf() will return the number of items it has...