import qualified Data.Conduit as C
import Data.Conduit ((.|))
import Data.Conduit.SafeWrite
main = C.runConduitRes $
C.yield "Hello World" .| safeSinkFile "hello.txt"
In any case, only successful termination of the process will result in the
output file being written. Early termination by throwing an exception will
cause the temporary file to be removed and no output will be produced.