Corrupted TTree in TFile opened on CASTOR

Dear all,
I am trying to open a file on CASTOR, fill it with a root tree and close it. What I do is the following:

TFile *outfile;
TString outstring;
TTree *tree;

tree = new TTree(“tree”,“data tree”);
outfile = TFile::Open(outstring,“RECREATE”);//outstring.Data());//(outstring,“RECREATE”);



where outstring is of the type "rfio:///…"
The file is correctly opened in the location I want and filled with data, but when I try to open it with root no trace of the TTree key is there. For example a .ls() command (once the root file is opened) yields no “KEY: TTree tree;1 data tree”, which is what I got when I created the file “locally” (i.e. producing the output in my local directory and not on CASTOR, with some slightly different code).
What am I doing wrong?
Thanks for your help.