sys.stdout.write('/some/directory/without/a/file\n')

def search_a_string():
    """
        reads from stdout and gets a regex from from sys.argv via argparse
        returns any found regexes back to stdout     
    """
argparser = argparse.ArgumentParser()
argparser.add_argument('my_grep_args', metavar='MY_GREP_ARGS', nargs='*')
print(my_grep_args)
for line in fileinput.input():
    sys.stdout.write('regex found {}\n'.format(line))
Make a file searching program that accepts a single regular expression with sys.argv.