why does this script continue looping and not end gracefully with the
output I want. I can't figure out where to put channel.close :-(

#!/usr/local/bin/ruby

require 'rubygems'
require 'net/ssh'
require "cgi"

def do_tail( session, file )
  session.open_channel do |channel|
    channel.on_data do |ch, data|
      puts "[#{file}] -> #{data}"
    end
    channel.exec "tail -f #{file}"
  end
end

session = Net::SSH.start( 'servername', 'username', 'password' ) do
|session|
  do_tail session, "/var/log/messages"
  session.loop
end

This is 99.99% example script from the net::ssh site I know, but I have
a modified version that I want to expand and use but it's driving me
mad trying to work out how to make the loop stop when the job is done.