Andrei Alexandrescu wrote: > No go if the file is a stream. Can it be done in one pass? No, because without knowing the number of lines, you cannot produce a uniform distribution. Unless you're willing to make a guess based on the file size.