diff --git a/src/python/adgui.py b/src/python/adgui.py
index 9d704a7d..2729d9c7 100755
--- a/src/python/adgui.py
+++ b/src/python/adgui.py
@@ -256,7 +256,7 @@ class adgui(QObject):
html = f"{s}"
elif level < ad.MSG_TRACE:
html = f"{s}"
- if not no_nl or s[-1] == '\n':
+ if html and (not no_nl or s[-1] == '\n'):
html += "
\n"
if s != "" and s != "\n":
new_bol = not no_nl or (s[-1] == '\n')