public void errorPrintln(String errorMessage) {
        System.err.println(errorMessage);
        if (writeToFile) {
            checkLogFile();
            printWriter.println(errorMessage);
            printWriter.flush();
        }
    }