>I was thinking that I can append result into the cursor, but I haven't yet tried.
Oh, right, that would probably be much faster than a loop.
If you decide to use this method, don't forget to replace "output.txt" with a random filename, to avoid multiuser conflicts.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)