added call to writeTemplate()