Database Ruby

require 'dbm'
d = DBM.new("data")
d["123"] = "123"
puts d["123"]  
d.close
puts d["123"]             # RuntimeError: closed DBM file
e = DBM.open("data")
e["123"]       
w=e.to_hash    
e.close
e["123"]                  # RuntimeError: closed DBM file
w["123"]