<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_genstrings_comments_to_file(localization_file, genstrings_err):
 """ Adds the comments produced by the genstrings script for duplicate keys. Args: localization_file (str):
 The path to the strings file. """


    errors_to_log = [line for line in genstrings_err.splitlines() if "used with multiple comments" not in line]

    if len(errors_to_log) > 0:
        logging.warning("genstrings warnings:\n%s", "\n".join(errors_to_log))

    loc_file = open_strings_file(localization_file, "a")

    regex_matches = re.findall(r'Warning: Key "(.*?)" used with multiple comments ("[^"]*" (& "[^"]*")+)',
                               genstrings_err)

    logging.info("Adding multiple comments from genstrings output")
    for regex_match in regex_matches:
        if len(regex_match) == 3:
            key = regex_match[0]
            comments = [comment.strip()[1:-1] for comment in regex_match[1].split("&")]

            logging.info("Found key with %d comments: %s", len(comments), key)

            loc_key = LocalizationEntry(comments, key, key)

            loc_file.write(unicode(loc_key))
            loc_file.write(u"\n")

    loc_file.close()