Read int from fgetc for EOF comparison - fixes #365

Signed-off-by: Benn Snyder <benn.snyder@gmail.com>