diff --git a/ansi2html/converter.py b/ansi2html/converter.py
index fefbff8..3016309 100755
--- a/ansi2html/converter.py
+++ b/ansi2html/converter.py
@@ -377,11 +377,11 @@ def _collapse_cursor(self, parts):
# Go back, deleting every token in the last 'line'
if part == CursorMoveUp:
- final_parts.pop()
-
if final_parts:
- while '\n' not in final_parts[-1]:
- final_parts.pop()
+ final_parts.pop()
+
+ while final_parts and '\n' not in final_parts[-1]:
+ final_parts.pop()
continue