diff --git a/ChangeLog b/ChangeLog
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+Version 0.0.3.0 2017-07-29 by luispedro
+	* Fix issue with creating files in separate directories
+
 Version 0.0.2.0 2017-05-30 by luispedro
 	* Add conduit version
 
diff --git a/Data/Conduit/SafeWrite.hs b/Data/Conduit/SafeWrite.hs
--- a/Data/Conduit/SafeWrite.hs
+++ b/Data/Conduit/SafeWrite.hs
@@ -6,7 +6,7 @@
 import qualified Data.Conduit.Combinators as CC
 import qualified Data.ByteString as B
 import           Data.IORef (newIORef, writeIORef, readIORef)
-import           System.FilePath (takeDirectory)
+import           System.FilePath (takeDirectory, takeBaseName)
 import           System.IO (hClose, openTempFile)
 import           System.Directory (renameFile, removeFile)
 import           Control.Monad (unless)
@@ -28,7 +28,7 @@
                             writeMove
     where
         acquire = do
-            (tname, th) <- openTempFile (takeDirectory finalname) finalname
+            (tname, th) <- openTempFile (takeDirectory finalname) (takeBaseName finalname)
             completed <- newIORef False
             return (tname, th, completed)
         writeMove (tname, th, completed) = do
diff --git a/System/IO/SafeWrite.hs b/System/IO/SafeWrite.hs
--- a/System/IO/SafeWrite.hs
+++ b/System/IO/SafeWrite.hs
@@ -3,7 +3,7 @@
     , syncFile
     ) where
 
-import           System.FilePath (takeDirectory)
+import           System.FilePath (takeDirectory, takeBaseName)
 import           System.Posix.IO (openFd, defaultFileFlags, closeFd, OpenMode(..))
 import           System.Posix.Unistd (fileSynchronise)
 import           Control.Exception (bracket, onException)
@@ -38,7 +38,7 @@
             -> (Handle -> IO a) -- ^ action to execute
             -> IO a
 withOutputFile finalname act = do
-    (tname, th) <- openTempFile (takeDirectory finalname) finalname
+    (tname, th) <- openTempFile (takeDirectory finalname) (takeBaseName finalname)
     (do
         r <- act th
         hClose th
diff --git a/System/IO/SafeWrite/Tests.hs b/System/IO/SafeWrite/Tests.hs
--- a/System/IO/SafeWrite/Tests.hs
+++ b/System/IO/SafeWrite/Tests.hs
@@ -11,7 +11,7 @@
 import           Control.Monad.IO.Class (liftIO)
 import           Control.Exception (throwIO)
 import           System.IO.Error (isDoesNotExistError, catchIOError)
-import           System.Directory (doesFileExist, removeFile)
+import           System.Directory (doesFileExist, removeFile, createDirectory, removeDirectory)
 import           System.IO (hPutStrLn)
 
 import System.IO.SafeWrite
@@ -45,12 +45,23 @@
 
 case_no_intermediate_output = do
     withOutputFile outname $ \h -> do
-        hPutStrLn h "Hello Worlld"
+        hPutStrLn h "Hello World"
         partial <- doesFileExist outname
         assertBool "Partial file should not exist before internal action ends" (not partial)
     (doesFileExist outname) >>= assertBool "Output file was not created"
     removeFile outname
 
+
+case_in_subdirectory = do
+    let subdir = "subdirectory_for_testing"
+        ofname = subdir ++ "/file.txt"
+
+    createDirectory subdir
+    withOutputFile ofname $ flip hPutStrLn "Hello World"
+    (doesFileExist ofname) >>= assertBool "Output file was not created"
+    removeFile ofname
+    removeDirectory subdir
+
 case_conduit_create_output = do
     C.runConduitRes $
         C.yield "Hello World" .| safeSinkFile outname
@@ -76,3 +87,15 @@
         ) .| safeSinkFile outname
     (doesFileExist outname) >>= assertBool "Output file was not created at the end of conduit processing"
     removeFile outname
+
+case_conduit_in_subdirectory = do
+    let subdir = "subdirectory_for_testing"
+        ofname = subdir ++ "/file.txt"
+
+    createDirectory subdir
+    C.runConduitRes $
+        C.yield "Hello World" .| safeSinkFile ofname
+    (doesFileExist ofname) >>= assertBool "Output file was not created"
+    removeFile ofname
+    removeDirectory subdir
+
diff --git a/safeio.cabal b/safeio.cabal
--- a/safeio.cabal
+++ b/safeio.cabal
@@ -1,8 +1,8 @@
 name:               safeio
-version:            0.0.2.0
+version:            0.0.3.0
 synopsis:           Write output to disk atomically
 description:        This package implements utilities to perform atomic output
-		    so as to avoid the problem of partial intermediate files.
+                    so as to avoid the problem of partial intermediate files.
 category:           IO
 author:             Luis Pedro Coelho
 maintainer:         Luis Pedro Coelho
@@ -19,7 +19,7 @@
                    Data.Conduit.SafeWrite
   ghc-options: -Wall
   build-depends:
-    base > 4 && < 5,
+    base > 4.8 && < 5,
     bytestring,
     conduit >= 1.0,
     conduit-combinators,
@@ -36,8 +36,7 @@
   ghc-options: -Wall
   hs-source-dirs: .
   build-depends:
-    base > 4 && < 5,
-    base > 4 && < 5,
+    base > 4.8 && < 5,
     bytestring,
     conduit >= 1.0,
     conduit-combinators,
