Matches the given Pattern against all lines in the given file, and replaces all matches with the replacement
generated by the given Function.
All unmatched lines and provided replacements are written into the file, with the order corresponding to the
original content. Newlines are automatically added to each line; this implies that an empty replacement string
will result in an empty line to be written.