in reply to while loop not exiting?

That code works fine for me...

Is there anything else in your script apart from that? Or perhaps something peculiar about $best_file we should know?