Renders and overrides Jinja2 template files

def render_template_file(file_name, context):
    """ Renders and overrides Jinja2 template files """
    with open(file_name, 'r+') as f:
        template = Template(f.read())
        output = template.render(context)
        f.seek(0)
        f.write(output)
        f.truncate()