Do you have a reason to take a screenshot, i.e. having Photoshop UI included in the shot? Can you explain what you are trying to achieve more closely. Why do you take a screenshot of a file you load to be saved to a file, what changes?
In general I'd recommend to use Photoshop scripting to automate what you would do manually in Photoshop like
1) Open template document
2) Open content document
3) Duplicate content layer in template and position it
4) Duplicate template doc
5) Flatten the duplicate and save to disk
6) Delete content layer from template and close content doc
7) go to 1)