It looks fine to me.
Also, I created a file with 500000 "words" [a, b, c .. z, aa, ab, ac... ba, bb, bc,... zz, etc]
the last ten are
I then instrumented the code to measure the time it takes to read the words in, and it toook about 0.05 seconds the first time round, and 0.16 s the second time round. So although I agree that it's inefficient to read the file twice, it's not as bad as it may seem.Code:qqkba rqkba sqkba tqkba uqkba vqkba wqkba xqkba yqkba zqkba
This of course assumes you're not reading the data from a network, slow CDROM or some such - in that case, I'd recommend copying the file to some local storage first.
--
Mats