in reply to reading a random line from a file

One thing you can do is to seek to a random position, and then read what is between two newlines.