private static void mergeSort(File file1, File file2, List<File> mergedFiles) {
		try {
			BufferedReader reader1 = new BufferedReader(new FileReader(file1));
			BufferedReader reader2 = new BufferedReader(new FileReader(file2));

			File mergeFile = File.createTempFile("merged_", null);
			mergedFiles.add(mergeFile);
			BufferedWriter writer = new BufferedWriter(new FileWriter(mergeFile));

			int num1 = Integer.parseInt(reader1.readLine());
			int num2 = Integer.parseInt(reader2.readLine());

			int finished = -1;
			while (true) {
				if (num1 < num2) {
					writer.append(String.valueOf(num1) + "\n");
					String line ;
					if ((line = reader1.readLine()) != null) {
						num1 = Integer.parseInt(line);
						continue;
					} else {
						finished = 1;
						break;
					}
				} else {
					writer.append(String.valueOf(num2) + "\n");
					String line ;
					if ((line = reader2.readLine()) != null) {
						num2 = Integer.parseInt(line);
						continue;
					} else {
						finished = 2;
						break;
					}
				}
			}
			if (finished == 1) {
				String line;
				writer.append(String.valueOf(num2) + "\n");
				while ((line = reader2.readLine()) != null) {
					writer.append(line + "\n");
				}
			} else if (finished == 2) {
				String line;
				writer.append(String.valueOf(num1) + "\n");
				while ((line = reader1.readLine()) != null) {
					writer.append(line + "\n");
				}				
			}
			reader1.close();
			reader2.close();
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}