title: Printing to a .csv file from a Random List
body: <p>When I create a random List of numbers like so:</p>
  
  <pre><code>columns = 10
  rows = 10
  for x in range(rows):
      a_list = []                                                    
      for i in range(columns):                                          
          a_list.append(str(random.randint(1000000,99999999)))     
      values = ",".join(str(i) for i in a_list)
      print values
  </code></pre>
  
  <p>then all is well.  </p>
  
  <p>But when I attempt to send the output to a file, like so:</p>
  
  <pre><code>sys.stdout = open('random_num.csv', 'w')                  
  for i in a_list:
      print ", ".join(map(str, a_list))
  </code></pre>
  
  <p>it is only the last row that is output 10 times.  How do I write the entire list to a .csv file ?</p>