title: Inserting text to end of line python
body: <p>I want to append some text to the end of a specific line in a text file, inside a loop.
  So far, I have the following:</p>
  
  <pre><code>batch = ['1', '2', '3', '4', '5']
  list = ['A', 'B', 'C']
  
  for i in list:
      for j in batch:
          os.chdir("/" + i + "/folder_" + j + "/")
  
          file = "script.txt"
          MD = "TEXT"
          with open(file) as templist:
              templ = templist.read().splitlines()
          for line in templ:
              if line.startswith("YELLOW"):
                  line += str(MD)
  </code></pre>
  
  <p>I am a newbie at python. Could you please help?</p>
  
  <p>EDIT: I've updated my script after (great) suggestions, but it still does not change my line.</p>