def intercept_file_option(argv):
    """
    Find and replace value of command line option for input file in given
    argv list.

    Returns tuple:
      * file_arg: the filename (value of -f option)
      * new_argv: argv with the filename replaced with "-" (if found)
    """
    file_arg = None # value of -f option in sys.argv
    file_idx = None # index of value of -f option in sys.argv

    # if the file is not specified, no change in argv is needed
    new_argv = argv

    for i, arg in enumerate(argv[1:], start=1):
        if arg != "-f":
            continue
        file_idx = i+1
        if len(argv) <= file_idx:
            # it looks like '-f' is the last option, let's not interfere
            break
        file_arg = argv[file_idx]
        new_argv = argv.copy()
        new_argv[file_idx] = "-"

    return file_arg, new_argv