#!/usr/bin/ruby class IO def rand_line find_all { rand(lineno) < 1; } [-1] end end puts ARGF.rand_line