title: Write a variable to a file in Python
body: <p>Lets say I have a python function which takes input of name, age, gender etc from the user I have a template from which I read and I have to write. For eg I have the following input:</p>
  <pre><code>Name: Ashish
  Age: 22
  Gender: Male
  Profession: Software Engineer
  </code></pre>
  <p>I have a template with many lines in the form of:</p>
  <pre><code>Hi, Name
  Your age is Age and you are Gender working as a Profession.....
  </code></pre>
  <p>I want to read from the template and write to a new file and add the variables to the output file dynamically without using the replace function is it possible to get output as this (for example):</p>
  <pre><code>Hi, Ashish
  Your age is 22 and you are Male working as a Software Engineer.....
  </code></pre>
  <p>I don't want to use replace function but want to read from the template file and write the variables dynamically to the output file. Help will be appreciated. I am working on the automation task for which I require reading from file. This is just an example:)</p>