Add user prompt for overwriting templates. Removed dependency on global variable.
Use safer and shorter reference to template, not dependent on a loop variable.