in reply to automated file move

The problem is a bit under-specified. The cycle to test a resource (read value, sleep, read value, sleep, etc.) is correct. Well, assuming that your print inside foreach is just a placeholder and you actually do some processing there such as getting the size and doing something with the file if size ... (your criteria here).

What is not clear is what you mean by "the file has stopped growing". I hope you don't conclude "hard disk full" when this happens... The semantics and dynamics of log file access are not known in your problem description. Based on what I read, the only thing that can be improved it fine-tuning the sleep interval ("stopped growing" means two consecutive reads yield the same size? or size doesn't change in 5 minutes? it is not clear ...). If you want the file to be moved when it reaches a certain size (popular option in handling logs), you can fine-tune your sleep based on the file growth speed (oh, well, not always easy to guesstimate, depending on the use scenario ...) and just move the file the first time it exceeds your size limit (that would be checked for in the foreach body.

Hard to give more details/opinions with only the info you provided, but your approach is good.