From: ts Date: 2000-11-15T02:25:05+09:00 Subject: [ruby-talk:6363] Re: rescue clause affecting IO loop behavior >>>>> "D" == David Alan Black writes: You don't have the same 'begin' D> begin D> puts "Line from first block." D> end until true With this 'begin' ruby don't test the first time. This mean that the block is always executed once D> begin D> puts "Line from second block." D> rescue D> d = "dummy exception handler" D> end until true Here for ruby you don't have a block 'begin' but a block 'rescue'. This mean that ruby will make the test before trying to enter in the block 'rescue' Perhaps ruby must test if it has a block 'rescue', or a block 'ensure' and skip the first test like it do with a block 'begin', I don't know ? For your example : # here line is nil # because you have a block 'begin' ruby don't call the first time # 'line.is_end?' and enter directly in the block begin # it read a line ==> now line is a String object line = fh.readline # it try to call the method String#is_end? and find it end until line.is_end? This is why it work The second case # here line is nil # because you don't have a block 'begin' but a block 'rescue' ruby will # make the test *before* trying to enter in the block, # this mean that it go directly to the until part begin line = fh.readline rescue puts $! + " while looking for END" exit # line is nil, and it will try to call the method Nil#is_end? # and don't find it, this is why it give the error. end until line.is_end? This is why your example work when you have a method associated with nil, and don't work otherwise Guy Decoux