This appears to be a Windows-specific problem - see http://bugs.python.org/issue1521491 for a similar issue.
Even better, a workaround given and explained at http://mail.python.org/pipermail/python-bugs-list/2005-August/029886.html, insert:
f.seek(f.tell())
between the read() and write() calls.