fix test for #305 (overwrite files)

Thanks a lot! But the tests seems to be slightly incorrect, appending rather than overwriting the temporary file (the 2nd test succeeds on the unpatched version).