Strip initial newlines from tangled output, so tangled Pandoc Markdown
has its metadata header at the start of the file.
diff --git a/lib/Anansi/Tangle.hs b/lib/Anansi/Tangle.hs
index 4a95633..7dee48b 100644
--- a/lib/Anansi/Tangle.hs
+++ b/lib/Anansi/Tangle.hs
@@ -19,6 +19,7 @@
 
 import           Prelude hiding (FilePath)
 
+import           Control.Monad (when)
 import qualified Control.Monad.State as S
 import qualified Control.Monad.RWS as RWS
 import qualified Data.ByteString.Char8 as ByteString
@@ -93,7 +94,8 @@
 			then formatPosition doc path
 			else const "\n")
 		(_, bytes) <- RWS.evalRWST (mapM_ putContent content) env state
-		writeFile' path bytes
+		let stripped = ByteString.dropWhile (== '\n') bytes
+		writeFile' path stripped
 
 formatPosition :: Document -> FilePath -> Position -> Text
 formatPosition doc = checkPath where
@@ -187,11 +189,9 @@
 	TangleState lastPos indent <- RWS.get
 	let expectedPos = Position (positionFile lastPos) (positionLine lastPos + 1)
 	RWS.put (TangleState pos indent)
-	if pos == expectedPos
-		then return ()
-		else do
-			TangleEnv _ format <- RWS.ask
-			RWS.tell (encodeUtf8 (format pos))
+	when (pos /= expectedPos) $ do
+		TangleEnv _ format <- RWS.ask
+		RWS.tell (encodeUtf8 (format pos))
 
 lookupMacro :: Monad m => Text -> Position -> TangleT m [Content]
 lookupMacro name pos = do
diff --git a/tests/Tests.hs b/tests/Tests.hs
index 6abd285..872b894 100644
--- a/tests/Tests.hs
+++ b/tests/Tests.hs
@@ -222,8 +222,7 @@
 	$expect $ equalTangle True [] blocks "file-1.hs"
 		""
 	$expect $ equalTangle True [] blocks "file-2.hs"
-		"\n\
-		\#line 0 \"test\"\n\
+		"#line 0 \"test\"\n\
 		\foo\n\
 		\bar\n\
 		\\n\
@@ -249,8 +248,7 @@
 	$expect $ equalTangle False [] blocks "file-1.hs"
 		""
 	$expect $ equalTangle False [] blocks "file-2.hs"
-		"\n\
-		\foo\n\
+		"foo\n\
 		\bar\n\
 		\\n\
 		\baz\n\
@@ -268,8 +266,7 @@
 	
 	-- test custom #line formatting
 	$expect $ equalTangle True [("anansi.line-pragma-hs", "#line ${line}")] blocks "file-2.hs"
-		"\n\
-		\#line 0\n\
+		"#line 0\n\
 		\foo\n\
 		\bar\n\
 		\\n\