public void writeToFile(String fileName, LinkedList<Data> results) {
        try {
            FileWriter fw = new FileWriter(fileName);
            String lineOut = "Iter,";
            for (int i = 0; i < simulations.length; i++) {
                lineOut += simulations[i] + ",";
            }
            fw.write(lineOut + "\n");

            LinkedList<LinkedList<Double>> averages = new LinkedList();
            for (int i = 0; i < results.size(); i++) {
                averages.add(results.get(i).getAverage());
            }

            for (int j = 0; j < averages.get(0).size(); j++) {
                lineOut = "" + j + ",";
                for (int i = 0; i < averages.size(); i++) {
                    lineOut += averages.get(i).get(j) + ",";
                }
                fw.write(lineOut + "\n");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }