Longest lines of file descending
Reading a file named on the command line is a common task.  I suggest making use of the ARGF to accomplish that.

Not all lines of the input are to be treated uniformly.  Since the first line is to be treated differently, I suggest defining lines to exclude it.

top_n, *lines = ARGF.to_a
puts lines.sort_by(&amp;:length).last(top_n.to_i).reverse