private static void executeFinalStep(String outputFileName,
			final GridProcessingManager gpm) throws IOException {
		List<Integer> history = gpm.getShortestHistory();
		String result = "";
		
		if (history.isEmpty()) {
			result = "No result";
		} else {
			for (int i = 0; i < history.size(); i++) {
				result += history.get(i) + (i % 40 == 39 ? "\n" : " ");
			}
		}
		
		FileWriter fstream = new FileWriter(outputFileName);
	    BufferedWriter out = new BufferedWriter(fstream);
	    out.write(result.trim());
	    out.close();
	    System.out.println(gpm.getVisited().size());
	}