diff --git a/Text/PrettyPrint/Mainland.hs b/Text/PrettyPrint/Mainland.hs
--- a/Text/PrettyPrint/Mainland.hs
+++ b/Text/PrettyPrint/Mainland.hs
@@ -688,7 +688,9 @@
                          showString "#line " .
                          shows (posLine p) .
                          showChar ' ' .
+                         showChar '"' .
                          shows (posFile p) .
+                         showChar '"' .
                          go x
     go (RLine i x)     = showString ('\n' : replicate i ' ') .
                          go x
@@ -742,12 +744,18 @@
     go (RString _ s x) = B.fromString s `mappend` go x
     go (RPos p x)      = B.singleton '\n' `mappend`
                          B.fromString "#line " `mappend`
-                         (go . renderCompact . ppr) (posLine p) `mappend`
+                         renderPosLine p `mappend`
                          B.singleton ' ' `mappend`
-                         (go . renderCompact . ppr) (posFile p) `mappend`
+                         renderPosFile p `mappend`
                          go x
     go (RLine i x)     = B.fromString ('\n':replicate i ' ') `mappend`
                          go x
+
+    renderPosLine :: Pos -> B.Builder
+    renderPosLine = go . renderCompact . ppr . posLine
+
+    renderPosFile :: Pos -> B.Builder
+    renderPosFile = go . renderCompact . enclose dquote dquote . ppr . posFile
 
 -- | Render and convert a document to 'L.Text' with #line pragmas. Uses a builder.
 prettyPragmaLazyText :: Int -> Doc -> L.Text
diff --git a/mainland-pretty.cabal b/mainland-pretty.cabal
--- a/mainland-pretty.cabal
+++ b/mainland-pretty.cabal
@@ -1,5 +1,5 @@
 name:           mainland-pretty
-version:        0.4.1.0
+version:        0.4.1.1
 cabal-version:  >= 1.6
 license:        BSD3
 license-file:   LICENSE
