title: Rewriting array to text file, need to put each part on new line
body: <p>I have a stock system.
  The data is written into the file like this: (product code, name, costprice, price, quantity)</p>
  
  <pre><code>1004, table, 10, 20, 45
  1005, chair, 6, 13, 30
  1006, lamp, 2, 5, 10
  </code></pre>
  
  <p>The code below is for updating the quantity of the stock:</p>
  
  <pre><code>def test():
      items = []
      itemname = input("Enter itemname: ")
      with open('Stockinventory.txt') as inputfile:
          for line in inputfile:
              items.append(line.strip().split(','))
  
      with open('Stockinventory.txt') as inputfile:
          for num, line in enumerate(inputfile, 0):
              if itemname in line:
                  newline = (items[num])
                  newline = line.split(", ")
                  print ("SIN: %s" % newline[0])
                  print ("Itemname: %s" % newline[1])
                  print ("Retail price: %s" % newline[2])
                  print ("Costprice: %s" % newline[3])
                  print ("Quantity Available: %s" % newline[4])
                  choice = input("Would you like to update quantity? y/n")
                  if choice == 'y':
                      newquantity = input("Enter new quantity: ")
                      newline[4] = newquantity
                      print(newline)
                      items[num] = newline
                      print(items)
                      writetrue = '1'
                  else:
                      startup()
  
      if writetrue == '1':
          f = open('Stockinventory.txt', 'w')
          f.write(str(items))
          f.close()
      else:
          print("No change")
          startup()
  </code></pre>
  
  <p>The code changes the quantity correctly but when I rewrite the array to the file, it looks like this:</p>
  
  <pre><code>[['1004', 'table', '10', '20', '30'], ['1005', ' chair', ' 6', ' 13', ' 30'], ['1006', ' lamp', ' 2', ' 5', ' 10']]
  </code></pre>
  
  <p>In this case, the quantity of the table was changed to 30. 
  How do I get the data written back to the file like it was originally?</p>