fixing new lines and duplicate shebang in templates, update #778