Added doPrint value to print only if no error