in reply to Re^2: -f not identifying .txt files
in thread -f not identifying .txt files

I think the solution has already been suggested, I would just like to point you to the documentation (readdir):

If you're planning to filetest the return values out of a readdir, you'd better prepend the directory in question. Otherwise, because we didn't chdir there, it would have been testing the wrong file.

Harry