def save_kwd_results(df, domains, outfile):
    """
    Save to pkl the ID's of notes in which keywords were found.
    The pickled dataframe contains a column per domain with a list of the keywords found in a note.

    Parameters
    ----------
    df: DataFrame
        dataframe with notes and results of keyword search
    domains: list
        list of domains, as they appear in the column names of the df
    outfile: str
        path to pkl file to write the results

    Returns
    -------
    None
    """
    matched_rows = df[domains].apply(any, axis=1)
    df = df.loc[matched_rows][['institution', 'MDN', 'NotitieID'] + domains]
    df.to_pickle(outfile)
    print(f"Results {len(df)=} are saved to {outfile}")
    return None