Cannot read / write TTree

Hi

I am trying to write a ttree in a file - Everything is done the proper way , like

[code] TFile *f1 = new TFile (filename.c_str (), “UPDATE”);

ttree->Fill() ;

f1->cd ();
tree->Write ();
f1->Write();
f1->Close ();
delete f1;
[/code]

when I am trying to execute , I am getting

Error in TFile::ReadBuffer: error reading all requested bytes from file TTJets_tree.root, got 228 of 300
Warning in TFile::Init: file TTJets_tree.root probably not closed, cannot read free segments
Warning in TFile::Init: file TTJets_tree.root has no keys
Error in TKey::Create: Cannot allocate 1889 bytes for ID = OBS Title = list of observables
Error in TKey::Create: Cannot allocate 4138 bytes for ID = StreamerInfo Title = Doubly linked list

which of course results that my file is not properly written/closed and cannot use it. What I am doing wrong ?

Thanks in advance

Could you post a short running script reproducing your problem?

Rene