added conditions for writing no more than maxErrors to errors.out file