diff --git a/Core/Export/SimulationToPython.cpp b/Core/Export/SimulationToPython.cpp
index db09a2c0befa7b27eb39944b0c56c02c1912bb51..241f6d6efdb352d9fb9838da3d9b1d9f36976527 100644
--- a/Core/Export/SimulationToPython.cpp
+++ b/Core/Export/SimulationToPython.cpp
@@ -155,7 +155,7 @@ std::string SimulationToPython::defineDetector(const ISimulation* simulation) co
         }
         result << ")\n";
     } else if (const auto* const det = dynamic_cast<const RectangularDetector*>(detector)) {
-        result << pyfmt::indent() << "\n";
+        result << "\n";
         result << pyfmt::indent() << "detector = ba.RectangularDetector(" << det->getNbinsX()
                << ", " << pyfmt::printDouble(det->getWidth()) << ", " << det->getNbinsY() << ", "
                << pyfmt::printDouble(det->getHeight()) << ")\n";
@@ -205,7 +205,7 @@ std::string SimulationToPython::defineDetector(const ISimulation* simulation) co
                << printFunc(detector)(detector->regionOfInterest()->getXup()) << ", "
                << printFunc(detector)(detector->regionOfInterest()->getYup()) << ")\n";
     }
-    result << pyfmt::indent() << "\n";
+    result << "\n";
     return result.str();
 }
 
@@ -408,11 +408,11 @@ std::string SimulationToPython::defineBackground(const ISimulation* simulation)
 std::string SimulationToPython::defineMain(SimulationToPython::EMainType mainType) {
     std::string result;
     if (mainType == RUN_SIMULATION) {
-        result = "if __name__ == '__main__': \n"
+        result = "if __name__ == '__main__':\n"
                  "    result = run_simulation()\n"
                  "    ba.plot_simulation_result(result)\n";
     } else if (mainType == SAVE_DATA) {
-        result = "if __name__ == '__main__': \n"
+        result = "if __name__ == '__main__':\n"
                  "    result = run_simulation()\n"
                  "    import sys\n"
                  "    if len(sys.argv)>=2:\n"