changed sys.err to filehandle