public void write_file(Parameters p, double running_time) {
        if (!p.log) {
            write_error("No Files Created: Logging Disabled");
            return;
        }

        write("Simulation Time: " + running_time + " sec");
        String name = p.log_dir + now() + "-log.log";
        try {
            PrintWriter out = new PrintWriter(name);
            out.print(debug.getText());
            out.close();
            write("Logfile created: " + name, Color.green);
            return;
        } catch (FileNotFoundException e) {
            write_error("File Writing Error: " + e.getMessage());
            File dir = new File(p.log_dir);
            dir.mkdir();
            write("Directory created: " + p.log_dir, Color.green);
        }

        try {
            PrintWriter out = new PrintWriter(name);
            out.print(debug.getText());
            out.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

        write("Logfile created: " + name, Color.green);
    }