Commit changes to file in case of command error