diff --git a/splunklib/modularinput/event_writer.py b/splunklib/modularinput/event_writer.py
index <HASH>..<HASH> 100755
--- a/splunklib/modularinput/event_writer.py
+++ b/splunklib/modularinput/event_writer.py
@@ -48,7 +48,7 @@ class EventWriter(object):
         else:
             self._out = TextIOWrapper(output)
 
-        if isinstance(output, TextIOBase):
+        if isinstance(error, TextIOBase):
             self._err = error
         else:
             self._err = TextIOWrapper(error)
diff --git a/tests/modularinput/test_event.py b/tests/modularinput/test_event.py
index <HASH>..<HASH> 100644
--- a/tests/modularinput/test_event.py
+++ b/tests/modularinput/test_event.py
@@ -144,9 +144,6 @@ class EventTestCase(unittest.TestCase):
         out = BytesIO()
         err = BytesIO()
 
-        outwrap = TextIOWrapper(out)
-        errwrap = TextIOWrapper(err)
-
         ew = EventWriter(out, err)
 
         expected_xml = ET.parse(data_open("data/event_maximal.xml")).getroot()
error in checking to see if error output is a TextIOBase

Also removed a couple unused objects in a test