added write error to file