open(file) do |f|
    while s = f.gets.chomp
      
    end
  end

だとエラーが出ます。
 in `test': private method `chomp' called for nil:NilClass (NoMethodError)

以下の一行だとうまくいくのに何ででしょう?

 puts f.gets.chomp

ところで、

 f.gets.class

するとStringなのになぜ?