I was curious how Python would handle this evil and non portable mess:
$ cat io.py
from string import printable
f = open('foo', 'w')
for i in range(0, 5):
f.write("hello\0world\n")
f = open('foo', 'r')
for l in f.readlines():
print ''.join(c if c in printable else '.' for c in l),
$ python io.py
hello.world
hello.world
hello.world
hello.world
hello.world