@SuppressWarnings("unchecked")
	private void initReduce() {
		//Initialize reduce variables
		recordsSplitToReduceWorkers = new ArrayList[config.getNumOfReducers()];
		completedReducePaths = new String[recordsSplitToReduceWorkers.length];
		for (int i = 0; i < recordsSplitToReduceWorkers.length; i++) {
			recordsSplitToReduceWorkers[i] = new ArrayList<Integer>();
		}
		/* First get the path of the intermediate file obtained
		 * by concatenating all the map files.
		 */
		String outputPath = config.getOutputFilePath();
		String[] splitOnPeriod = outputPath.split("\\.");
		splitOnPeriod[0] += "_intermediate";
		
		if (splitOnPeriod.length == 2) {
			splitOnPeriod[1] = "." + splitOnPeriod[1];
		}
		
		String newPath = "";
		
		for (int i = 0; i < splitOnPeriod.length; i++) {
			newPath += splitOnPeriod[i];
		}
		intermediateFilepath = newPath;
		
		/* Now, actually write that file. */
		BufferedWriter outWriter = null;
		int numCharsSeen = 0;
		try {
			outWriter = Files.newBufferedWriter(Paths.get(intermediateFilepath), Charset.defaultCharset());
		    for (String path : completedMapPaths) {
		    	BufferedReader br = null;
				br = Files.newBufferedReader(Paths.get(path), Charset.defaultCharset());
				String curLine;
		        try {
					while ( (curLine = br.readLine()) != null) {
						//First map the current record to a reduce worker
						//TODO Hash the key, not the entire line
						String[] commaSplit = curLine.split(",");
						//Skip the first character which is <
						String key = commaSplit[0].substring(1);
						int index = Math.abs(key.hashCode()) % config.getNumOfReducers();
						recordsSplitToReduceWorkers[index].add(numCharsSeen);
						outWriter.write(curLine);
						outWriter.newLine();
						numCharsSeen += config.getRecordLength() + 1;
					}
				} catch (IOException e) {
					e.printStackTrace();
				}
		    }
			outWriter.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		for (int i = 0; i < recordsSplitToReduceWorkers.length; i++) {
			unperformedReduces.add(recordsSplitToReduceWorkers[i]);
		}
		
		initReduceWorkers();
		
		/*ArrayList<Integer> first = recordsSplitToReduceWorkers[0];
		BufferedReader br = null;
		try {
			for (Integer i: first) {
				br = Files.newBufferedReader(Paths.get(newPath), Charset.defaultCharset());
				br.skip(i);
				System.out.println(br.readLine());
			}
		} catch (IOException e) {
			e.printStackTrace();
		}*/
	}