Copy first, never edit the original
The entire operation hinges on one line: templateFile.makeCopy(). Every run produces a fresh copy in your output folder; the template stays untouched. The first time I skipped this step I spent twenty minutes figuring out why my placeholders had already been replaced when I opened the template — the previous run had eaten them.
Pass a destination folder as the second argument to makeCopy. Without it, the copy lands in Drive root, and after ten runs you have ten unlabeled files with no obvious home. DriveApp.getFolderById() takes the folder ID from the URL when you have that folder open in Drive (the long alphanumeric string after /folders/).
The file ID for your template comes from the same place: open the doc in Docs, copy the ID segment from the URL between /d/ and /edit. Hard-code it as a constant at the top of the script rather than looking it up at runtime — one less API call per invocation.