in reply to while loop not exiting?
Is there anything else in your script apart from that? Or perhaps something peculiar about $best_file we should know?