getsとreadline
IO#getsとIO#readlineでは、EOFに達したときの振る舞いが異なります。getsはnilを返しますが、readlineはEOFErrorをraiseします。
まずはgetsを試します。
while line = DATA.gets puts line end __END__ 1 22 333
実行結果です。
1 22 333
次にreadlineを試します。
while line = DATA.readline puts line end __END__ 1 22 333
実行結果です。
1 22 333 ...:in `readline': end of file reached (EOFError) from ...