permulate template and output to a file