def line_filter(regexp, lines):
    """
    Filter each line of input by a regular expression.

    If the regular expression is not matched, then the line is not output.
    """
    output = []
    for line in lines:
        match = regexp.match(line)
        if match:
            output.append(line)

    return output