<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write_targets(targets, **params):
 """Writes version info into version file"""

    handler = ReplacementHandler(**params)
    for target, regexer in regexer_for_targets(targets):
        with open(target) as fh:
            lines = fh.readlines()
        lines = replace_lines(regexer, handler, lines)
        with open(target, "w") as fh:
            fh.writelines(lines)
    if handler.missing:
        raise Exception(
            "Failed to complete all expected replacements: %r" % handler.missing
        )