reformat file
roll back if failed