def readlines(fname, &block)

      i = 0

      File.open(fname, 'rb') do |file|

        loop do

          i = i + 1

          line = file.gets || break

          block.call(line, i)
        end
      end
    end
def readlines(fname, &block)

      i = 0

      File.open(fname, 'rb') do |file|

        loop do

          i = i + 1

          line = file.gets || break

          block.call(line, i)
        end
      end
    end
A helper method, ensuring we're reading line by line (and not all the
 lines at once)