diff --git a/xfel_calibrate/calibrate.py b/xfel_calibrate/calibrate.py
index 9319c304644e67686962232c75154deb7d8d8de7..78738dcc716c42a2f928ca1ef5706e4e2cc40401 100755
--- a/xfel_calibrate/calibrate.py
+++ b/xfel_calibrate/calibrate.py
@@ -503,15 +503,15 @@ def create_finalize_script(fmt_args, temp_path, job_list):
     :param temp_path: Path to temporary folder to run slurm job
     :param job_list: List of slurm jobs
     """
-    tmpl = Template('''
+    tmpl = Template("""#!/usr/bin/env python3
                     import sys
                     from xfel_calibrate.finalize import finalize
 
-                    finalize(joblist={{joblist}}, 
+                    finalize(joblist={{joblist}},
                              finaljob=sys.argv[1],
                              run_path='{{run_path}}',
                              out_path='{{out_path}}',
-                             project='{{project}}', 
+                             project='{{project}}',
                              calibration='{{calibration}}',
                              author='{{author}}',
                              version='{{version}}',
@@ -519,8 +519,8 @@ def create_finalize_script(fmt_args, temp_path, job_list):
                              data_path='{{in_folder}}',
                              request_time='{{request_time}}',
                              submission_time='{{submission_time}}')
-                    
-                    ''')
+
+                    """)
 
     fmt_args['joblist'] = job_list
     f_name = os.path.join(temp_path, "finalize.py")