diff --git a/compile b/compile
index 3a300d82c5c3476962cc952854ffe6bf141f293a..295890fa6177ffa253c2dac364894316b4f1b70e 100755
--- a/compile
+++ b/compile
@@ -53,7 +53,7 @@ else
 	esac
 fi
 
-$TWEEGO_EXE -o "bin/FC_pregmod.html" src/ || build_failed="true"
+$TWEEGO_EXE -o "bin/FC_pregmod_tmp.html" src/ || build_failed="true"
 
 # Revert AlphaDisclaimer for next compilation
 git checkout -- src/gui/mainMenu/AlphaDisclaimer.tw
@@ -64,4 +64,5 @@ then
 fi
 
 #Make the output prettier, replacing \t with a tab and \n with a newline
-sed -i -e '/^.*<div id="store-area".*$/s/\\t/\t/g' -e '/^.*<div id="store-area".*$/s/\\n/\n/g'  bin/FC_pregmod.html
+sed -i -e '/^.*<div id="store-area".*$/s/\\t/\t/g' -e '/^.*<div id="store-area".*$/s/\\n/\n/g' bin/FC_pregmod_tmp.html \
+   && mv bin/FC_pregmod_tmp.html bin/FC_pregmod.html
diff --git a/compile-git b/compile-git
index d462d20c07065fefe92c0832dcc3ff8b20fe1850..f077fe27905091abd6b7511ae45a4e9607d140bd 100755
--- a/compile-git
+++ b/compile-git
@@ -35,9 +35,10 @@ else
 	esac
 fi
 
-$TWEEGO_EXE -o "bin/FC_pregmod_$HASH.html" src/
+$TWEEGO_EXE -o "bin/FC_pregmod_${HASH}_tmp.html" src/
 
 #Make the output prettier, replacing \t with a tab and \n with a newline
-sed -i -e '/^<div id="store-area".*$/s/\\t/\t/g' -e '/^<div id="store-area".*$/s/\\n/\n/g'  "bin/FC_pregmod_$HASH.html"
+sed -i -e '/^<div id="store-area".*$/s/\\t/\t/g' -e '/^<div id="store-area".*$/s/\\n/\n/g'  "bin/FC_pregmod_${HASH}_tmp.html" \
+	&& mv "bin/FC_pregmod_${HASH}_tmp.html" "bin/FC_pregmod_${HASH}.html"
 
 echo "FC_pregmod_$HASH.html compilation finished."