diff --git a/CHANGES.txt b/CHANGES.txt
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,5 +1,7 @@
 Changelog for Extra
 
+0.8
+    Fix a bug in writeFileEncoding/writeFileUTF8
 0.7
     Fix for missing case in withNumCapabilities
 0.6
diff --git a/Generate.hs b/Generate.hs
--- a/Generate.hs
+++ b/Generate.hs
@@ -36,7 +36,7 @@
         ,""] ++
         ["import " ++ x | x <- mods]
     writeFileBinaryChanged "test/TestGen.hs" $ unlines $
-        ["{-# LANGUAGE ExtendedDefaultRules, ScopedTypeVariables #-}"
+        ["{-# LANGUAGE ExtendedDefaultRules, ScopedTypeVariables, ViewPatterns #-}"
         ,"module TestGen(tests) where"
         ,"import TestUtil"
         ,"default(Maybe Bool,Int,Double,Maybe (Maybe Bool),Maybe (Maybe Char))"
diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@
 * `Control.Exception.Extra.retry` provides a function that retries an `IO` action a number of times.
 * `System.Environment.Extra.lookupEnv` is a functional available in GHC 7.6 and above. On GHC 7.6 and above this package reexports the version from `System.Environment` while on GHC 7.4 and below it defines an equivalent version.
 
-The module "Extra" documents all functions provided by this library. Modules such as "Data.List.Extra" provide extra functions over "Data.List" and also reexport "Data.List". Users are recommended to replace "Data.List" imports with "Data.List.Extra" if they need the extra functionality.
+The module `Extra` documents all functions provided by this library. Modules such as `Data.List.Extra` provide extra functions over `Data.List` and also reexport `Data.List`. Users are recommended to replace `Data.List` imports with `Data.List.Extra` if they need the extra functionality.
 
 ## Which functions?
 
diff --git a/extra.cabal b/extra.cabal
--- a/extra.cabal
+++ b/extra.cabal
@@ -1,7 +1,7 @@
 cabal-version:      >= 1.10
 build-type:         Simple
 name:               extra
-version:            0.7
+version:            0.8
 license:            BSD3
 license-file:       LICENSE
 category:           Development
diff --git a/src/Control/Monad/Extra.hs b/src/Control/Monad/Extra.hs
--- a/src/Control/Monad/Extra.hs
+++ b/src/Control/Monad/Extra.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE CPP #-}
 
 -- | Extra functions for "Control.Monad".
 --   These functions provide looping, list operations and booleans.
@@ -16,7 +17,9 @@
     ) where
 
 import Control.Monad
+#if __GLASGOW_HASKELL__ < 709
 import Control.Applicative
+#endif
 import Data.Maybe
 
 -- General utilities
diff --git a/src/System/IO/Extra.hs b/src/System/IO/Extra.hs
--- a/src/System/IO/Extra.hs
+++ b/src/System/IO/Extra.hs
@@ -53,6 +53,8 @@
 -- | A strict version of 'readFile'. When the string is produced, the entire
 --   file will have been read into memory and the file handle will have been closed.
 --   Closing the file handle does not rely on the garbage collector.
+--
+-- > \(filter isHexDigit -> s) -> fmap (== s) $ withTempFile $ \file -> do writeFile file s; readFile' file
 readFile' :: FilePath -> IO String
 readFile' file = withFile file ReadMode $ \h -> do
     s <- hGetContents h
@@ -82,15 +84,19 @@
 
 -- | Write a file with a particular encoding.
 writeFileEncoding :: TextEncoding -> FilePath -> String -> IO ()
-writeFileEncoding enc file x = withFile x WriteMode $ \h -> do
+writeFileEncoding enc file x = withFile file WriteMode $ \h -> do
     hSetEncoding h enc
     hPutStr h x
 
 -- | Write a file with the 'utf8' encoding.
+--
+-- > \s -> withTempFile $ \file -> do writeFileUTF8 file s; fmap (== s) $ readFileUTF8' file
 writeFileUTF8 :: FilePath -> String -> IO ()
 writeFileUTF8 = writeFileEncoding utf8
 
 -- | Write a binary file.
+--
+-- > \s -> withTempFile $ \file -> do writeFileBinary file s; fmap (== s) $ readFileBinary' file
 writeFileBinary :: FilePath -> String -> IO ()
 writeFileBinary file x = withBinaryFile file WriteMode $ \h -> hPutStr h x
 
diff --git a/test/TestGen.hs b/test/TestGen.hs
--- a/test/TestGen.hs
+++ b/test/TestGen.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE ExtendedDefaultRules, ScopedTypeVariables #-}
+{-# LANGUAGE ExtendedDefaultRules, ScopedTypeVariables, ViewPatterns #-}
 module TestGen(tests) where
 import TestUtil
 default(Maybe Bool,Int,Double,Maybe (Maybe Bool),Maybe (Maybe Char))
@@ -172,6 +172,9 @@
     testGen "listTest (listFilesInside $ return . not . isPrefixOf \".\" . takeFileName)    [\"bar.txt\",\"foo\" </> \"baz.txt\",\".foo\" </> \"baz2.txt\", \"zoo\"] [\"bar.txt\",\"zoo\",\"foo\" </> \"baz.txt\"]" $ listTest (listFilesInside $ return . not . isPrefixOf "." . takeFileName)    ["bar.txt","foo" </> "baz.txt",".foo" </> "baz2.txt", "zoo"] ["bar.txt","zoo","foo" </> "baz.txt"]
     testGen "listTest (listFilesInside $ const $ return False) [\"bar.txt\"] []" $ listTest (listFilesInside $ const $ return False) ["bar.txt"] []
     testGen "isWindows == (os == \"mingw32\")" $ isWindows == (os == "mingw32")
+    testGen "\\(filter isHexDigit -> s) -> fmap (== s) $ withTempFile $ \\file -> do writeFile file s; readFile' file" $ \(filter isHexDigit -> s) -> fmap (== s) $ withTempFile $ \file -> do writeFile file s; readFile' file
+    testGen "\\s -> withTempFile $ \\file -> do writeFileUTF8 file s; fmap (== s) $ readFileUTF8' file" $ \s -> withTempFile $ \file -> do writeFileUTF8 file s; fmap (== s) $ readFileUTF8' file
+    testGen "\\s -> withTempFile $ \\file -> do writeFileBinary file s; fmap (== s) $ readFileBinary' file" $ \s -> withTempFile $ \file -> do writeFileBinary file s; fmap (== s) $ readFileBinary' file
     testGen "captureOutput (print 1) == return (\"1\\n\",())" $ captureOutput (print 1) == return ("1\n",())
     testGen "withTempFile doesFileExist == return True" $ withTempFile doesFileExist == return True
     testGen "(doesFileExist =<< withTempFile return) == return False" $ (doesFileExist =<< withTempFile return) == return False
