truncating file before writing new indexes