def METHOD_NAME(self, prog, path):
    dir, base = os.path.split(path)
    list = self.findfiles(dir, base, self.recvar.get())
    list.sort()
    self.close()
    pat = self.engine.getpat()
    print("Searching %r in %s ..." % (pat, path))
    hits = 0
    try:
        for fn in list:
            try:
                with open(fn, errors='replace') as f:
                    for lineno, line in enumerate(f, 1):
                        if line[-1:] == '\n':
                            line = line[:-1]
                        if prog.search(line):
                            sys.stdout.write("%s: %s: %s\n" %
                                             (fn, lineno, line))
                            hits += 1
            except OSError as msg:
                print(msg)
        print(("Hits found: %s\n"
              "(Hint: right-click to open locations.)"
              % hits) if hits else "No hits.")
    except AttributeError:
        # Tk window has been closed, OutputWindow.text = None,
        # so in OW.write, OW.text.insert fails.
        pass