Fix fscanf.

This reverts commit 179dfed which fixed a specific case leaving fscanf partially broken (closes gh-1172)
The problem was in ungetc() not clearing the end-of-file flag.