# Unintuitive debug/3 - format/2 interaction

**URL:** <https://swi-prolog.discourse.group/t/unintuitive-debug-3-format-2-interaction/9715>\
**Category:** Help!\
**Tags:** printing, terminal\
**Created:** [June 28, 2026, 2:38am UTC](https://swi-prolog.discourse.group/t/unintuitive-debug-3-format-2-interaction/9715 "2026-06-28T02:38:25Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [June 28, 2026, 7:49am UTC](https://swi-prolog.discourse.group/t/unintuitive-debug-3-format-2-interaction/9715/2 "2026-06-28T07:49:33Z")

</div>

It is indeed about the streams. debug/3 writes to `user_error`, format/2 to `current_output`, which is normally `user_output`. `user_error` is _unbuffered_, while `user_output` is _line buffered_ (when talking to a terminal; _fully buffered_ otherwise). So, the debug/3 write immediately. the `baz` is buffered until the `~n`. To get what you want, use flush\_output/1 or change `user_output` to be unbuffered using set\_stream/2.

---

_[View the full topic](https://swi-prolog.discourse.group/t/unintuitive-debug-3-format-2-interaction/9715)._
