truncate the output file before writing