wrote code to print errors to a file