diff --git a/ntpclients/ntpq.py b/ntpclients/ntpq.py
index b0fc841..7e034db 100644
--- a/ntpclients/ntpq.py
+++ b/ntpclients/ntpq.py
@@ -17,6 +17,7 @@ import getopt
 import hashlib
 import os
 import re
+import readline
 import resource
 import socket
 import sys
@@ -69,10 +70,12 @@ if str is bytes:  # Python 2
     def string_escape(s):
         return s.decode('string_escape')

-    # Originally these only triggered if sys.stdout.encoding != "UTF-8":
-    # Unfortunately sometimes sys.stdout.encoding lies
-    sys.stdout = codecs.getwriter('UTF-8')(sys.stdout)
-    sys.stderr = codecs.getwriter('UTF-8')(sys.stderr)
+    if sys.stdout.encoding != "UTF-8":
+        forced_utf8 = True
+        sys.stdout = codecs.getwriter('UTF-8')(sys.stdout)
+    if sys.stderr.encoding != "UTF-8":
+        forced_utf8 = True
+        sys.stderr = codecs.getwriter('UTF-8')(sys.stderr)

 else:  # Python 3
     import io

