TST: core: fix tofile file positioning test

Python 2 I/O is a thin wrapper on FILE* C-API. All Python code must
follow the ANSI C requirement (see man fopen) that there is a seek or a
flush between reads and writes, otherwise the behavior is undefined.
Whether this is required depends on the CRT implementation; glibc
doesn't seem to require it, but OSX apparently does.

Fixes gh-4189