Remove unneeded newlines from templates' ends