public void write(String line) {
        try {
            writer.print(line);
            writer.flush();
        } catch (Exception e){
            log.writeErr("Could not write to file.\nFile: " + file.getAbsolutePath() + "\nError was: " + e.getMessage());
            close();
        }
    }