# TFile creating un-loadable .root files

**URL:** <https://root-forum.cern.ch/t/tfile-creating-un-loadable-root-files/50932>\
**Category:** Newbie\
**Created:** [July 23, 2022, 10:13pm UTC](https://root-forum.cern.ch/t/tfile-creating-un-loadable-root-files/50932 "2022-07-23T22:13:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![apiccone15](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/apiccone15/32/30386_2.png) [@apiccone15](https://root-forum.cern.ch/u/apiccone15)\
**Post date:** [July 23, 2022, 10:13pm UTC](https://root-forum.cern.ch/t/tfile-creating-un-loadable-root-files/50932/1 "2022-07-23T22:13:35Z")

</div>

_ROOT Version:_ 6.20/06  
_Platform:_ Linux Server (ROOT through views LCG\_97a:x86\_64-centos7-gcc8-opt)  
_Compiler:_ Not Provided

* * *

Hi,

I’ve been running into an issue with writing objects to a new root file. For context, I have a Delphes .root file that I’m applying a macro to, and at the end of the macro I’ve included this block,

```auto
TFile*out = new TFile("WHSigBkg.root", "RECREATE");
hmjj -> Write();
hMET -> Write();
hMT -> Write();
out -> Write();
out -> Close();

```

where all pointers that aren’t “out” are referring to TH1F histograms. Upon loading this macro and executing its function, the new .root file is not immediately loaded, although it is created. If I try and load it manually, I get a long list of errors and warnings including

```auto
/users/alecp1/ROOTspace/WH/WHSigBkg.root:1:5: warning: null character ignored [-Wnull-character]

```

```auto
/users/alecp1/ROOTspace/WH/WHSigBkg.root:1:7: error: source file is not valid UTF-8

```

and

```auto
/users/alecp1/ROOTspace/WH/WHSigBkg.root:1:8: error: expected unqualified-id

```

triggering a fatal error (too many errors emitted). Interestingly enough, even a simple macro

```auto
void test()
{
TFile out("test.root", "RECREATE");
out.Write();
out.Close();
}

```

yields the same result.

I’m very new to using the ROOT framework and about as new to C++, so I entirely expect the issue to be on my end, but I’m not sure what the issue could be. Any thoughts?

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [July 25, 2022, 9:01am UTC](https://root-forum.cern.ch/t/tfile-creating-un-loadable-root-files/50932/2 "2022-07-25T09:01:23Z")

</div>

> [@apiccone15](#):
>
> Interestingly enough, even a simple macro
> 
> ```auto
> void test()
> {
> TFile out("test.root", "RECREATE");
> out.Write();
> out.Close();
> }
> 
> ```
> 
> yields the same result.

I do not get any error with this simple macro:

```auto
% root test.C
   ------------------------------------------------------------------
  | Welcome to ROOT 6.27/01 https://root.cern |
  | (c) 1995-2022, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for macosx64 on Jul 25 2022, 08:02:01 |
  | From heads/master@v6-25-02-1873-g56c28ff3b8 |
  | With Apple clang version 12.0.5 (clang-1205.0.22.9) |
  | Try '.help'/'.?', '.demo', '.license', '.credits', '.quit'/'.q' |
   ------------------------------------------------------------------

root [0] 
Processing test.C...
root [1] .q

```

---

<div class="post-metadata">

**Author:** ![jalopezg](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jalopezg/32/25844_2.png) [@jalopezg](https://root-forum.cern.ch/u/jalopezg)\
**Post date:** [July 25, 2022, 10:20am UTC](https://root-forum.cern.ch/t/tfile-creating-un-loadable-root-files/50932/3 "2022-07-25T10:20:49Z")

</div>

> [@apiccone15](#):
>
> ```auto
> void test()
> {
> TFile out("test.root", "RECREATE");
> out.Write();
> out.Close();
> }
> 
> ```

Could you copy here the `root` command line that you are using to run this macro (and any other `root` invocation that you are using)?

Cheers,  
J.
