Something like
zero_output_file(fh, len(file))
flush()
fill_output_file(fh, data)
with an oops in line 3? zero_output_file(fh, len(file))
flush()
fill_output_file(fh, data)
with an oops in line 3?