I've implemented the second version in my code and it works just fine, but was suddenly struck with the doubt as to which is actually more efficient, and given how that bit of code runs a few hundred (if not thousand) times each time the program is run, it might be somewhat relevant, if only for a second or two less of delay.
Just run each version a lot of times. 1 million is a popular n for memory, but for disk, I'd say start at 10k. You'll probably want to generate the file programmatically.