In my code, I open all emails in a library, then write an array containing all relevant data for each (we're mostly interested in the name as a kind of ID).
I then iterate through the array, calling doStuff, which in turn calls writeNew.
Based upon my countless failures, I proved the following. I set a global Boolean value to false. In writeNew, I set that value to true (in the completefunc section). I display the value at the beginning of each iteration of doStuff. That global value is always reported to be false. This confirms the more complicated results I've been getting with actual data: what happens in writeNew stays in writeNew, global or not.