attachRecording method in WatirMaker script

I modified the watirmaker script
http://www.hanselman.com/blog/content/binary/WatirMaker.rb.txt
to contain the following method right under startRecording

def attachRecording

    # initialize IE
    require 'watir'
    @watirie = Watir::IE.attach(:title,/#{$windowName}/)
    @ie = @watirie.getIE()
    @ie.visible = TRUE

    browserEvents = WIN32OLE_EVENT.new( @ie, 'DWebBrowserEvents2' )
    browserEvents.on_event { |*args| browserEventHandler( *args ) }

    # print script header
    puts "##//////////////////////////////////////////////////////////////////////////////////////////////////"
    puts "##"
    puts "## Watir script recorded by WatirMaker."
    puts "##"
    puts "##//////////////////////////////////////////////////////////////////////////////////////////////////"
    puts ""
    puts "#requires"
    puts "require 'watir'"
    puts ""
    puts "#includes"
    puts "include Watir"
    puts ""
    puts "ie = IE.attach(:title,/#{$windowName}/}"
    # puts "ie.set_fast_speed()" this doesn't seem to work so well
with multiple frames
    puts ""

    # capture events
    catch( :done ) {
       loop {
          WIN32OLE_EVENT.message_loop
       }
    }

    # IE takes a moment to close.
    # Making it invisible in the interim produces a slightly nicer
user experience.
    @ie.visible = FALSE
end

And at the end of the file I inserted:

wm = WatirMaker.new
wm.startRecording if !$windowName
wm.attachRecording if $windowName

I get the following error:

watirmaker.rb:168: [BUG] Segmentation fault
ruby 1.8.5 (2006-08-25) [i386-mswin32]

This is found in the attachRecording method at the following:

          WIN32OLE_EVENT.message_loop

I start the command like this:

ruby -s watirmaker.rb -windowName="MyTitle"

Any thoughts?

Matthew