Move delete file outside of record loop