Corrected error in template.txt and tidied script