title: Python-Issue writing to CSV file
body: <p>I can print results to terminal but unable to write to csv file</p>
  
  <p>full file:<a href="https://1drv.ms/u/s!AizscpxS0QM4hJo5SnYOHAcjng-jww" rel="nofollow noreferrer">https://1drv.ms/u/s!AizscpxS0QM4hJo5SnYOHAcjng-jww</a></p>
  
  <pre><code> datapath = '1.json'
  
  data = json.load(open(datapath))
  
  with open('1.json') as file:
    data = json.load(file)
  
  for element in data['RoleDetailList']:
   if 'RoleName' in element.keys():
     s = element['RoleName']
         #print s
  
   with open('roleassign.csv', 'wt') as file:
    file.write('Role,Policy\n')
    for policy in element['AttachedManagedPolicies']:
      c = s + ',' + policy['PolicyName']
      #print c
      file.write(c + '\n')
  </code></pre>
  
  <p>In csv file i get only headers, when uncomment <code>print c</code> i see lines are printed into terminal (output)</p>
  
  <p>some of the lines from output:</p>
  
  <pre><code>ADFS-amtest-ro,pol-amtest-ro
  adfs-host-role,pol-amtest-ro
  aws-elasticbeanstalk-ec2-role,AWSElasticBeanstalkWebTier
  </code></pre>