diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+# 1.5.1
+
+- Removing trailing whitespace sometimes restored necessary whitespace in the
+  wrong spot
+
 # 1.5
 
 - Fix inconsistent formatting within align and wide sub-docs on narrow layouts
diff --git a/prettyprinter.cabal b/prettyprinter.cabal
--- a/prettyprinter.cabal
+++ b/prettyprinter.cabal
@@ -1,5 +1,5 @@
 name:                prettyprinter
-version:             1.5.0
+version:             1.5.1
 cabal-version:       >= 1.10
 category:            User Interfaces, Text
 synopsis:            A modern, easy to use, well-documented, extensible pretty-printer.
diff --git a/src/Data/Text/Prettyprint/Doc/Internal.hs b/src/Data/Text/Prettyprint/Doc/Internal.hs
--- a/src/Data/Text/Prettyprint/Doc/Internal.hs
+++ b/src/Data/Text/Prettyprint/Doc/Internal.hs
@@ -1460,17 +1460,20 @@
 removeTrailingWhitespace :: SimpleDocStream ann -> SimpleDocStream ann
 removeTrailingWhitespace = go (RecordedWhitespace [] 0)
   where
-    commitSpaces
+    commitWhitespace
         :: [Int] -- Withheld lines
         -> Int -- Withheld spaces
         -> SimpleDocStream ann
         -> SimpleDocStream ann
-    commitSpaces [] 0 = id
-    commitSpaces [] 1 = SChar ' '
-    commitSpaces [] n = SText n (T.replicate n " ")
-    commitSpaces [i] n = SLine i . commitSpaces [] n
-    commitSpaces (_:is) n = SLine 0 . commitSpaces is n
+    commitWhitespace is0 n0 = commitLines is0 . commitSpaces n0
+      where
+        commitLines [] = id
+        commitLines (i:is) = foldr (\_ f -> SLine 0 . f) (SLine i) is
 
+        commitSpaces 0 = id
+        commitSpaces 1 = SChar ' '
+        commitSpaces n = SText n (T.replicate n " ")
+
     go :: WhitespaceStrippingState -> SimpleDocStream ann -> SimpleDocStream ann
     -- We do not strip whitespace inside annotated documents, since it might
     -- actually be relevant there.
@@ -1493,7 +1496,7 @@
         SEmpty -> foldr (\_i sds' -> SLine 0 sds') SEmpty withheldLines
         SChar c rest
             | c == ' ' -> go (RecordedWhitespace withheldLines (withheldSpaces+1)) rest
-            | otherwise -> commitSpaces
+            | otherwise -> commitWhitespace
                                withheldLines
                                withheldSpaces
                                (SChar c (go (RecordedWhitespace [] 0) rest))
@@ -1504,14 +1507,14 @@
                 isOnlySpace = strippedLength == 0
             in if isOnlySpace
                 then go (RecordedWhitespace withheldLines (withheldSpaces + textLength)) rest
-                else commitSpaces
+                else commitWhitespace
                         withheldLines
                         withheldSpaces
                         (SText strippedLength
                                stripped
                                (go (RecordedWhitespace [] trailingLength) rest))
         SLine i rest -> go (RecordedWhitespace (i:withheldLines) 0) rest
-        SAnnPush ann rest -> commitSpaces
+        SAnnPush ann rest -> commitWhitespace
                                  withheldLines
                                  withheldSpaces
                                  (SAnnPush ann (go (AnnotationLevel 1) rest))
diff --git a/test/Testsuite/Main.hs b/test/Testsuite/Main.hs
--- a/test/Testsuite/Main.hs
+++ b/test/Testsuite/Main.hs
@@ -74,6 +74,12 @@
             , testCase "Reduce to single trailing newline"
                        removeTrailingWhitespaceInTrailingNewlines
             ]
+        , testGroup "removeTrailingWhitespace restores indentation in the wrong spot (#93)"
+            [ testCase "Don't restore indentation in the wrong spot"
+                       removeTrailingWhitespaceDontRestoreIndentationInTheWrongSpot
+            , testCase "Preserve leading indentation"
+                       removeTrailingWhitespacePreserveIndentation
+            ]
         ]
     ]
 
@@ -277,3 +283,16 @@
         actual = renderStrict (layoutSmart (LayoutOptions (AvailablePerLine 12 1)) doc)
         expected = "/Fallback\n Fallback\n Too wide!!!!!"
     in assertEqual "" expected actual
+
+removeTrailingWhitespaceDontRestoreIndentationInTheWrongSpot :: Assertion
+removeTrailingWhitespaceDontRestoreIndentationInTheWrongSpot
+  = let sdoc :: SimpleDocStream ()
+        sdoc = SLine 2 (SLine 0 (SChar 'x' SEmpty))
+        sdoc' = SLine 0 (SLine 0 (SChar 'x' SEmpty))
+    in assertEqual "" sdoc' (removeTrailingWhitespace sdoc)
+
+removeTrailingWhitespacePreserveIndentation :: Assertion
+removeTrailingWhitespacePreserveIndentation
+  = let sdoc :: SimpleDocStream ()
+        sdoc = SLine 2 (SChar 'x' SEmpty)
+    in assertEqual "" sdoc (removeTrailingWhitespace sdoc)
