If fgets fail, then resource leak...
Merge pull request #1871 from mecking/patch-1

If fgets fail, then resource leak...