static File waitForGeneratedFile(File outputPath) {
		while (true) {
			File[] files = outputPath.listFiles(new FileFilter() {
				public boolean accept(File f) {
					if (!f.isFile())
						return false;
					else if (f.length() == 0)
						return false;
					else if (f.getName().endsWith(".part"))
						return false;
					else
						return true;
				}
			});

			if (files.length == 0) {
				try {
					Thread.sleep(300);
				} catch (InterruptedException ignored) {
				}
				continue;
			}

			if (files.length > 1) {
				System.err.println("More than one output file");
			}

			return files[files.length - 1];
		}
	}