# The current directory (root) is not associated with a file error when looping over input files

**URL:** <https://root-forum.cern.ch/t/the-current-directory-root-is-not-associated-with-a-file-error-when-looping-over-input-files/54716>\
**Category:** Newbie\
**Created:** [May 3, 2023, 4:33pm UTC](https://root-forum.cern.ch/t/the-current-directory-root-is-not-associated-with-a-file-error-when-looping-over-input-files/54716 "2023-05-03T16:33:36Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [May 3, 2023, 4:38pm UTC](https://root-forum.cern.ch/t/the-current-directory-root-is-not-associated-with-a-file-error-when-looping-over-input-files/54716/2 "2023-05-03T16:38:46Z")

</div>

[Before “`out_tree->Write();`”, try to add](https://root-forum.cern.ch/t/where-to-open-tfile-when-using-ttree-write/54695/4): `out_file->cd();`

---

_[View the full topic](https://root-forum.cern.ch/t/the-current-directory-root-is-not-associated-with-a-file-error-when-looping-over-input-files/54716)._
