Create a Random object and then, each time you want a random number, call its Next method. It's the same regardless of what you intend to use the random number for. Of course, you're going to have to apply some appropriate limits or you'll get all lines in the second file associated with the first line in the first file more often than not. As for what those limits should be, that's nothing to do with programming because they would be the same as the limits you would use if you were doing the whole thing with pen and paper.