check return value of fgets and exit main loop if EOF is received
styling change: remove uneeded parentheses around dereferenced pointer