diff --git a/pyqode/core/api/utils.py b/pyqode/core/api/utils.py
index <HASH>..<HASH> 100644
--- a/pyqode/core/api/utils.py
+++ b/pyqode/core/api/utils.py
@@ -334,6 +334,8 @@ class TextHelper(object):
         """
         Removes trailing whitespaces and ensure one single blank line at the
         end of the QTextDocument.
+
+        ..deprecated: since pyqode 2.6.3, document is cleaned on disk only.
         """
         editor = self._editor
         value = editor.verticalScrollBar().value()
@@ -359,16 +361,16 @@ class TextHelper(object):
                         removed.add(line + j)
         editor._modified_lines -= removed
 
-        # # ensure there is only one blank line left at the end of the file
-        # i = self.line_count()
-        # while i:
-        #     line = self.line_text(i - 1)
-        #     if line.strip():
-        #         break
-        #     self.remove_last_line()
-        #     i -= 1
-        # if self.line_text(self.line_count() - 1):
-        #     editor.appendPlainText('')
+        # ensure there is only one blank line left at the end of the file
+        i = self.line_count()
+        while i:
+            line = self.line_text(i - 1)
+            if line.strip():
+                break
+            self.remove_last_line()
+            i -= 1
+        if self.line_text(self.line_count() - 1):
+            editor.appendPlainText('')
 
         # restore cursor and scrollbars
         text_cursor = editor.textCursor()
Mark clean_document as deprecated