private void outputAndCompare(String line) throws ControllerException {
        output.println(line);
        output.flush();

        if (gui != null) {
            gui.outputFileUpdated();
            gui.setCurrentOutputLine(outputLinesCounter);
        }

        outputLinesCounter++;

        if (comparisonFile != null) {
            try {
                String compareLine = comparisonFile.readLine();

                if (gui != null)
                    gui.setCurrentComparisonLine(compareLinesCounter);

                compareLinesCounter++;

                if (!compareLineWithTemplate(line, compareLine)) {
                    comparisonFailed = true;
                    comparisonFailureLine = compareLinesCounter;
                    displayMessage("Comparison failure at line " + comparisonFailureLine,
                                       true);
                    stopMode();
                }
            } catch (IOException ioe) {
                throw new ControllerException("Could not read comparison file");
            }
        }
    }