everytime you use _str, it creates a new temporary string. The variable filePathName never changes, so the condition will always stay true if it was at the beginning of the loop.

Also, why is there a wait(1) in that loop?