Is there a way to reliably override IO#close ?

My first attempt

  f = File.open( "test.txt", "w" )
  def f.close
    puts "close called"
    super
  end
  f.puts "test"
  f.close

only works when I explicitly call close as in the example, but not in 
something like

  File.open( "test.txt", "w" ) do |f|
    def f.close
      puts "close called"
      super
    end
    f.puts "test"
  end

Any ideas?

TIA
Pit