fmemopen: fix eof handling, hopefully right this time