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 and fscanf's get() messing up with EOF.