truncate output file before writing