truncate to avoid partial writes