diff --git a/ChangeLog.md b/ChangeLog.md
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -4,6 +4,10 @@
 
 ## Released changes
 
+### 0.2.1.1
+
+- fix errors due to long Alloy code by starting timeout after transferring code
+
 ### 0.2.1.0
 
 - enable to abort instance generation early by using timeout
diff --git a/call-alloy.cabal b/call-alloy.cabal
--- a/call-alloy.cabal
+++ b/call-alloy.cabal
@@ -1,13 +1,13 @@
 cabal-version: 1.12
 
--- This file has been generated from package.yaml by hpack version 0.34.2.
+-- This file has been generated from package.yaml by hpack version 0.33.0.
 --
 -- see: https://github.com/sol/hpack
 --
--- hash: db841f71ac1e6d568aa7c8d4f6574b06cdf77fea00a6cf3ae0c74880c12eb083
+-- hash: a6397f9e52550d7e13e9e9b7b80fdbdc15cd29ab28396f6c2ad8dbd8cf0774b2
 
 name:           call-alloy
-version:        0.2.1.0
+version:        0.2.1.1
 synopsis:       A simple library to call Alloy given a specification
 description:    Please see the README on GitHub at <https://github.com/marcellussiegburg/call-alloy#readme>
 category:       Language
diff --git a/src/Language/Alloy/Call.hs b/src/Language/Alloy/Call.hs
--- a/src/Language/Alloy/Call.hs
+++ b/src/Language/Alloy/Call.hs
@@ -150,13 +150,13 @@
       }
   pout <- listenForOutput hout
   perr <- listenForOutput herr
-  maybe (return ()) (void . startTimeout hin hout herr ph) $ timeout config
 #ifndef mingw32_HOST_OS
   hSetBuffering hin NoBuffering
 #endif
   hPutStr hin content
   hFlush hin
   hClose hin
+  maybe (return ()) (void . startTimeout hin hout herr ph) $ timeout config
   out <- getOutput pout
   err <- getOutput perr
   printContentOnError ph
