Right, I have narrowed it down to something to do with the array in my original. I think the FOR EACH may be incorrect.

Anth, are you still using the array in your script ?