Generates a file from a template