implement write_errors_to_file