public static void sed(InputStream inputStream, OutputStream outputStream, Map<Pattern, String> patternReplacements) throws IOException {
		if(patternReplacements == null || patternReplacements.isEmpty()) {
			return;
		}

		Scanner scanner = new Scanner(inputStream).useDelimiter(Pattern.compile("\n"));
		while(scanner.hasNext()) {
			String line = scanner.next();
			String next = null;
			for (Map.Entry<Pattern, String> patternReplacement : patternReplacements.entrySet()) {
				Matcher matcher;
				if(next == null) {
					matcher = patternReplacement.getKey().matcher(line);
				} else {
					matcher = patternReplacement.getKey().matcher(next);
				}
				next = matcher.replaceAll(patternReplacement.getValue());
			}
			if(next == null) {
				throw new RuntimeException("Woh nelly! This is bad. There is no reason this should ever happen!");
			}
			next += "\n";

			outputStream.write(next.getBytes());
		}
	}