Fix tmpfile cleanup for windows (itertools not supported), Fix #6209

Rather than continue the list comprehensions that have given trouble
previously, I just did it with an easy-to-follow nested loop.

@cvrebert I'd be happy to make any changes you suggest.  I've tested this, and it seems to work beautifully, and should work on Windows.