title: Python updating a text file adding headers and their corresponding values
body: <p>I have a text file named headerValue.txt which contains the following data:-</p>
  
  <pre><code>Name   Age
  sam    22
  Bob    21
  </code></pre>
  
  <p>I am trying to write a python script that would add a new header called 'Eligibility'.
  It would read the lines from the text file and check if the age is more than 18, then it will print 'True' underneath 'Eligibility' header and also add one more header named 'Adult' and print a 'yes' underneath and 'no' if the age is less than 18.</p>
  
  <p>Since in the text file the age of both is more than 18. The output will something be like:-</p>
  
  <pre><code>Name    Age    Eligibility    Adult
  sam     22       True         yes
  Bob     21       True         yes
  </code></pre>
  
  <p>code snippet:-</p>
  
  <pre><code>fo =open("headerValue.txt", "r")
  data = fo.readlines()
  for line in data:
      if "Age" in line:
          if int(Age) &gt; 18:
              Eligibility = "True"
              Adult = "yes"
  </code></pre>
  
  <p>I am kinda stuck here since I am new to python. Any help how to update the text file and add headers with its values?Thanks</p>