def get_blacklist_scans(subject_id, blacklist_path, new_id=None):
    """
    Finds all entries in <blacklist_path> that belong to the participant with
    ID <subject_id>. If <new_id> is given, it modifies the found lines to
    contain the new subject's ID.
    """
    try:
        with open(blacklist_path, 'r') as blacklist:
            lines = blacklist.readlines()
    except IOError:
        lines = []

    entries = []
    for line in lines:
        if subject_id in line:
            if new_id is not None:
                line = line.replace(subject_id, new_id)
            entries.append(line)
    return entries