import re


def replace_in_file(pattern, repl, file):
    """Replace one `pattern` match to `repl` in file `file`."""

    file_content = open(file, "rt", encoding="utf-8").read()
    new_file_content = re.sub(pattern, repl, file_content, 1, re.M)
    open(file, "wt", encoding="utf-8").write(new_file_content)
    return not file_content == new_file_content