write in file if error