diff --git a/scripts/pylib/twister/twisterlib/handlers.py b/scripts/pylib/twister/twisterlib/handlers.py index e14c86719a7..5dd4340bc5e 100755 --- a/scripts/pylib/twister/twisterlib/handlers.py +++ b/scripts/pylib/twister/twisterlib/handlers.py @@ -422,7 +422,7 @@ def monitor_serial(self, ser, halt_event, harness): # is available yet. if serial_line: # can be more lines in serial_line so split them before handling - for sl in serial_line.decode('utf-8', 'ignore').splitlines(): + for sl in serial_line.decode('utf-8', 'ignore').splitlines(keepends=True): log_out_fp.write(strip_ansi_sequences(sl).encode('utf-8')) log_out_fp.flush() if sl := sl.strip():