Courier Font

1234567890

abcdefghij


until file.eof?

  case file.read(1)

  when "\n"

    if (new_line_count = 0)

      new_line_pos = file.pos - 1

      new_line_count += 1

    end

  when "#"

    sharp_pos = file.pos - 1 if sharp_pos == -1

  when "$"

    dollar_pos = file.pos - 1 if dollar_pos == -1

  end

 

  break if sharp_pos > 0 and dollar_pos > 0 and new_line_count > linenum

end

 

if (sharp_pos >= 0 and dollar_pos > 0)

  file.seek(sharp_pos, IO::SEEK_SET)

  puts file.read(dollar_pos - sharp_pos + 1)

end