truncate file before updating