public void writeData(String filename){
		try {

			File dir = new File("Data/");
			if (!Files.exists(dir.toPath())) {
				dir.mkdirs();
			}
			int num=1;
			String name=filename+num;
			File file = new File("Data/"+name+".txt");
			while(Files.exists(file.toPath())){
				num++;
				name=filename+num;
				file = new File("Data/"+name+".txt");
			}
			FileWriter fw = new FileWriter(file);
			BufferedWriter bw = new BufferedWriter(fw);
			for(int i=0;i<moveHistory.size();i++){
				bw.write("===================================");
				bw.newLine();
				bw.write("Trial#: "+i+"\tNumber of Moves: "+numMoves.get(i));
				bw.newLine();
				bw.write("Solve Time: "+timeFinished.get(i)+" ms");
				bw.newLine();
				bw.write("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
				bw.newLine();
				bw.write("Button to Image Number Map");
				bw.newLine();
				int col=(int)Math.sqrt(grid.getSize());
				int row=grid.getSize()/col;
				String divLine="";
				for(int l=0;l<col;l++)
					divLine+="------";
				for(int j=0;j<row;j++){
					bw.write(divLine);
					bw.newLine();
					for(int k=0;k<col;k++){
						bw.write("| "+button2imageMap[j*col+k]+" ");
					}
					bw.write("|");
					bw.newLine();
					
				}
				bw.write(divLine);
				bw.newLine();
				bw.write("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
				bw.newLine();
				bw.write("Button Number\tTime Pressed (ms)");
				bw.newLine();
				ArrayList<long[]> temp=moveHistory.get(i);
				for(int j=0;j<temp.size();j++){
					bw.write(temp.get(j)[0]+"\t"+temp.get(j)[1]);
					bw.newLine();
				}
				bw.write("===================================");
				bw.newLine();
			}
			
			
			bw.close();
 

		} catch (IOException e) {
			e.printStackTrace();
		}
	}