diff --git a/markdown-unlit.cabal b/markdown-unlit.cabal
--- a/markdown-unlit.cabal
+++ b/markdown-unlit.cabal
@@ -1,9 +1,11 @@
--- This file has been generated from package.yaml by hpack version 0.8.0.
+-- This file has been generated from package.yaml by hpack version 0.21.2.
 --
 -- see: https://github.com/sol/hpack
+--
+-- hash: 1ed9462425c5de84a4149bff9c95c17ee3c2c60b718cb4673c63fae99d454686
 
 name:             markdown-unlit
-version:          0.4.0
+version:          0.4.1
 synopsis:         Literate Haskell support for Markdown
 category:         Development
 homepage:         https://github.com/sol/markdown-unlit#readme
@@ -26,19 +28,23 @@
       src
   ghc-options: -Wall
   build-depends:
-      base == 4.*
+      base ==4.*
     , base-compat
   exposed-modules:
       Text.Markdown.Unlit
+  other-modules:
+      Paths_markdown_unlit
   default-language: Haskell2010
 
 executable markdown-unlit
   main-is: Main.hs
+  other-modules:
+      Paths_markdown_unlit
   hs-source-dirs:
       driver
   ghc-options: -Wall
   build-depends:
-      base == 4.*
+      base ==4.*
     , base-compat
     , markdown-unlit
   default-language: Haskell2010
@@ -48,19 +54,20 @@
   main-is: Spec.hs
   hs-source-dirs:
       src
-    , test
+      test
   ghc-options: -Wall
   cpp-options: -DTEST
   build-depends:
-      base == 4.*
+      QuickCheck
+    , base ==4.*
     , base-compat
     , directory
-    , hspec == 2.*
-    , QuickCheck
+    , hspec ==2.*
     , silently
     , stringbuilder
     , temporary
   other-modules:
       Text.Markdown.Unlit
       Text.Markdown.UnlitSpec
+      Paths_markdown_unlit
   default-language: Haskell2010
diff --git a/src/Text/Markdown/Unlit.hs b/src/Text/Markdown/Unlit.hs
--- a/src/Text/Markdown/Unlit.hs
+++ b/src/Text/Markdown/Unlit.hs
@@ -42,13 +42,15 @@
   --
   case break (== "-h") args of
     (xs, ["-h", fileName, infile, outfile]) ->
-      fmap (unlit fileName $ mkSelector xs) (readFile infile) >>= writeFile outfile
+      fmap (unlit fileName $ mkSelector xs) (readFileUtf8 infile) >>= writeFileUtf8 outfile
     _ -> do
       name <- getProgName
       hPutStrLn stderr ("usage: " ++ name ++ " [selector] -h label infile outfile")
       exitFailure
     where
       mkSelector = fromMaybe ("haskell" :&: Not "ignore") . parseSelector . unwords
+      readFileUtf8 name = openFile name ReadMode >>= \h -> hSetEncoding h utf8 >> hGetContents h
+      writeFileUtf8 name str = withFile name WriteMode (\h -> hSetEncoding h utf8 >> hPutStr h str)
 
 unlit :: FilePath -> Selector -> String -> String
 unlit fileName selector = unlines . concatMap formatCB . filter (toP selector . codeBlockClasses) . parse
