truncate file before writing to it