Fixing bugs with template generator

Turns out it didn't really work, fixing issue with sorting of exercises
as well as not correctly, and starting over when hitting new lines.