Strip whitespaces added by decode() function
diff --git a/tests/scripts/generate_test_code.py b/tests/scripts/generate_test_code.py
index ccb2d5f..33da990 100755
--- a/tests/scripts/generate_test_code.py
+++ b/tests/scripts/generate_test_code.py
@@ -97,8 +97,9 @@
             line = parent.next() # Python 2
         if line:
             self.line_no += 1
-            # Convert byte array to string with correct encoding
-            return line.decode(sys.getdefaultencoding())
+            # Convert byte array to string with correct encoding and
+            # strip any whitespaces added in the decoding process.
+            return line.decode(sys.getdefaultencoding()).strip() + "\n"
         return None
     next = __next__