# Output does not redirect in expected order

**URL:** <https://root-forum.cern.ch/t/output-does-not-redirect-in-expected-order/49348>\
**Category:** Newbie\
**Tags:** python\
**Created:** [March 24, 2022, 4:38pm UTC](https://root-forum.cern.ch/t/output-does-not-redirect-in-expected-order/49348 "2022-03-24T16:38:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mwilkins](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/mwilkins/32/28332_2.png) [@mwilkins](https://root-forum.cern.ch/u/mwilkins)\
**Post date:** [March 24, 2022, 4:38pm UTC](https://root-forum.cern.ch/t/output-does-not-redirect-in-expected-order/49348/1 "2022-03-24T16:38:33Z")

</div>

When I redirect `stdout` to a log file, ROOT output always appears at the top of the file, regardless of its sequence in the script. If I don’t redirect it, it appears where I would expect. Is there some kind of shell magic to get the output to appear where it logically should? Reproducer:

* * *

[test.py](https://root-forum.cern.ch/uploads/short-url/rUnhTD0Q10rd8MW29zTrokji6s7.py) (42 Bytes)

```auto
python test.py

```

output:

```nohighlight
first

RooFit v3.60 -- Developed by Wouter Verkerke and David Kirkby 
                Copyright (C) 2000-2013 NIKHEF, University of California & Stanford University
                All rights reserved, please read http://roofit.sourceforge.net/license.txt

```

compared with

```auto
python test.py > test.log
cat test.log

```

output:

```nohighlight
RooFit v3.60 -- Developed by Wouter Verkerke and David Kirkby 
                Copyright (C) 2000-2013 NIKHEF, University of California & Stanford University
                All rights reserved, please read http://roofit.sourceforge.net/license.txt

first

```

* * *

_ROOT Version:_ 6.24/06  
_Platform:_ macOS  
_Compiler:_ Not Provided

* * *

---

<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:** [March 24, 2022, 5:46pm UTC](https://root-forum.cern.ch/t/output-does-not-redirect-in-expected-order/49348/2 "2022-03-24T17:46:31Z")

</div>

`python -u ...`

[Stack Overflow → How can I flush the output of the print function (unbuffer python output)?](https://stackoverflow.com/questions/230751/how-can-i-flush-the-output-of-the-print-function-unbuffer-python-output)
