public static void printGRNToFile(final String fileName, final Grn grn, final double[][] results) {
    NumberFormat formatter = new DecimalFormat("###.#########");
    try{
      File file =new File(fileName);

      //if file doesnt exists, then create it
      boolean created = false;
      if(!file.exists()){
        file.createNewFile();
        created = true;
      }

      //true = append file
      FileWriter fileWritter = new FileWriter(file, true);
      BufferedWriter bufferWritter = new BufferedWriter(fileWritter);

      if (created) {
        for (int i = 0; i < grn.tfProteins.length - grn.numberOfInputs; i++)
          bufferWritter.write("TF"+i+" ");
        for (int i = 0; i < grn.numberOfInputs; i++)
          bufferWritter.write("I"+i+" ");
        for (int i = 0; i < grn.pProteins.length; i++)
          bufferWritter.write("P"+i+" ");
        bufferWritter.write("\n");
      }

      for (int t = 0; t < results.length; t++) {
        for (int i = 0; i < results[t].length; i++)
          bufferWritter.write(formatter.format(results[t][i])+" ");
        bufferWritter.write("\n");
      }
      bufferWritter.close();
      fileWritter.close();
    }
    catch(IOException e){
      e.printStackTrace();
    }
  }