> Thanks, but in my case it doesn't help me further Sorry, should have been more specific. What happens if you try this? from StringIO import StringIO f=open('file.dat', 'r+b') ff = StringIO() ff.write(f.read(-1)) ff.seek(0) ff.write(chr(123)) Alex.