I replied in
Shree's previous thread, because that
thread seemed to have more info about what I believe the main difficulty here is - ensuring that the numbers are unique. Trying to delete duplicates after the fact is still going to require some way of
detecting duplicates. And for ten million numbers, this may be nontrivial. The problem here is comparable to the one in the original post, so I figured as long as it has to be solved, it's better to eliminate duplicates
before they are written to the file.
Having said that though, I note that the code above has a simple bug which
ensures that the number at the end of each line is duplicated at the beginning of the next line. Removing that bug may be enough to generate files that
look, to the casual eye, like they have no duplicates. If you need to
ensure this, well, see the other thread for more discussion.