diff --git a/output.R b/output.R
index ec385809eac5fe9141784c98286a815140e3c615..498dbc305334041bbe98f56abf34143fb33b1997 100644
--- a/output.R
+++ b/output.R
@@ -1,3 +1,4 @@
+#!/usr/bin/env Rscript
 # |  (C) 2006-2020 Potsdam Institute for Climate Impact Research (PIK)
 # |  authors, and contributors see CITATION.cff file. This file is part
 # |  of REMIND and licensed under AGPL-3.0-or-later. Under Section 7 of
diff --git a/scripts/insertheader/insertheader.R b/scripts/insertheader/insertheader.R
index 1ecab22f8c4ad0b115c3bbe9839c2dde6ee5d490..807797e6f02492b3027535d55278f4f621eb20d2 100644
--- a/scripts/insertheader/insertheader.R
+++ b/scripts/insertheader/insertheader.R
@@ -17,7 +17,7 @@ insertheader <- function(maindir=".",
                                       ".spam",".xlsx",".xls", ".sh","files",".md",".RData", ".jpg",
                                       ".png",".cff", ".rds", ".aux", ".log", ".out", ".pdf",
                                       ".tex", ".htm", ".css", ".bib", ".ref", ".mif", ".gmif", ".gdx",
-                                      ".lst", ".git-id", ".csv", ".gcsv", ".Rdata", ".prn", ".cmd", ".put", 
+                                      ".lst", ".git-id", ".csv", ".gcsv", ".Rdata", ".prn", ".cmd", ".put",
                                       ".IN", ".awk", ".MON", ".CFG", ".mod", ".SCEN", ".inc"),
                          comments=c(".R"="#", ".Rmd"="#",".gms"="***",".cfg"="#",".csv"="*",".cs2"="*",
                                     ".cs3r"="*",".cs4r"="*",".sh"="#",".txt"="#"),
@@ -85,7 +85,7 @@ insertheader <- function(maindir=".",
 
     # insert header after line 0
     withcomment <- paste(co,key,header)
-    f <- append(f,withcomment,after = 0)
+    f <- append(f,withcomment,after = ifelse(!length(tmp), 0, tmp[1] - 1))
     writefile <- TRUE
     done <- c(done,file)
 
diff --git a/start.R b/start.R
index 138e9919613d852c1aa9e5bc021510eabdae875f..89df977ded0836000555425f9a7f14a39a320a95 100755
--- a/start.R
+++ b/start.R
@@ -1,10 +1,10 @@
+#!/usr/bin/env Rscript
 # |  (C) 2006-2020 Potsdam Institute for Climate Impact Research (PIK)
 # |  authors, and contributors see CITATION.cff file. This file is part
 # |  of REMIND and licensed under AGPL-3.0-or-later. Under Section 7 of
 # |  AGPL-3.0, you are granted additional permissions described in the
 # |  REMIND License Exception, version 1.0 (see LICENSE file).
 # |  Contact: remind@pik-potsdam.de
-#!/usr/bin/env Rscript
 library(lucode)
 
 #' Usage: