Extra space.
Drop getImportedTemplates().
Remove extension.
TemplateIterator::valid() rewinds.
It should work without now.
Proper headers.