close file before delete