Switch to proper for-loop in createWindowClone

This may address #1934 at least partially. Since #1934 does not happen to me, I cannot test it. Still, this patch uses a better way to iterate an array.