Rewrites each() in print() to use while & for