Fixed newline handling in template processing.