import re


def output_content(content, print_output, text_filter, headline):
    """
    Builds the human readable output return from stdout commands according to print_output and text_filter
    Args:
        content: stdout returned from running ad hoc command or job
        print_output: if True human readable is shown to user
        text_filter: if provided than human readable will include only lines in the content that contains this text
        headline: headline of the human readable text

    Returns: human readable text

    """
    output_text = ' '
    if print_output:
        filtered_content = ''
        if text_filter:
            for line in content.split("\n"):
                if re.search(fr'{text_filter.lower()}', line.lower()):
                    filtered_content = '\n'.join([filtered_content, line])
        add_filter_data = f'Filtered text: {text_filter}\n' if text_filter else ''
        output_text = headline + add_filter_data + (filtered_content if text_filter else content) + '\n'
    return output_text