title: how to .writerow() to only 1 row in csv file?
body: <p>Currently in my code it changes the 3rd row but for all rows, I want it to only change the row with the entered <code>GTIN</code> by the user.</p>
  
  <p>Current code:</p>
  
  <pre><code>file=open("stock.csv")
  stockfile= csv.reader(file)
  for line in stockfile:
      if GTIN in line:
          currentstock= line[2]
          targetstock = line[3]
          newstock = (int(currentstock) - int(Quantity))
          currentstock = str(currentstock)
          targetstock = str(targetstock)
          newstock = str(newstock)
      if newstock &lt; targetstock :
          import csv
          reader = csv.reader(open('stock.csv',"r"))
          new = csv.writer(open('out.csv',"w"))
          for line in reader:
              new.writerow([line[0], line[1], newstock , line[3]])
  </code></pre>
  
  <p>Output in file (it changes all numbers in 3rd column):</p>
  
  <pre><code>86947367,banana,1,40
  78364721,apple,1,20
  35619833,orange,1,30
  84716491,sweets,1,90
  46389121,chicken,1,10
  </code></pre>
  
  <p>How can I only change the row with the <code>GTIN</code> the user enters?</p>