title: How to read comma separated values from a text file, then output result to a text file?
body: <p>I need to create a program that will add numbers read from a text file separated by commas. i.e.</p>
  <p>in <code>file.txt</code>:</p>
  <pre class="lang-none prettyprint-override"><code>1,2,3
  4,5,6
  7,8,9
  </code></pre>
  <p>So far I have the simple code:</p>
  <pre><code>x = 1
  y = 2
  z = 3
  
  sum = x + y + z
  
  print(sum)
  </code></pre>
  <p>I'm not sure how I would assign each number in the text file to <code>x</code>, <code>y</code> and <code>z</code>.</p>
  <p>What I would like is that it will iterate through each line in the text file, this would be with a simple loop.</p>
  <p>However I also do not know how I would then output the results to another text file.
  i.e. <code>answers.txt</code>:</p>
  <pre class="lang-none prettyprint-override"><code>6
  15
  24
  </code></pre>