When you close a Root file, all objects in memory associated
with this file are deleted. In your case, you should not close
the file or, if you close the file, you must reopen it and get
the Tree header in memory again.
Before closing a file containing a Tree, you must write the Tree
header on this file.
file->cd(); // in case your current directory is not file
tree->Write(); //this will write the Tree header
Look also at the discussion at URL:
http://root.cern.ch/root/roottalk/roottalk98/0145.html
Rene Brun