in reply to Script being caught up, somewhere. Causing infinite loop.

I think that all you really need to do to remove your infinite loops is change the while to foreach

(this is just after a quick scan there might be other problems)

-enlil