Getting a random line from a file – and a question!!!
line = IO.readlines('some_file')
c = rand*line.length.to_i
Very simple logic and it can be easily understood by just looking at the code itself. No explanation needed. If someone knows a better way to do it then please post it in the comments. BTW..thats in ruby.