how do you print to .csv for each ID in Python
<pre><code>import urllib
import re
import csv

player_code = open("Desktop/OHL PYTHON/test2.txt").read()

player_code = player_code.split("\r")

for pc in player_code:
    htmlfile = urllib.urlopen( "http://www.eliteprospects.com/iframe_player_stats_small.php?player="+pc+"")

    htmltext = htmlfile.read()  
    regex = '&lt;font color="#000099"&gt;(.+?)&lt;/font&gt;'  
    pattern = re.compile(regex)
    team = re.findall(pattern,htmltext)
    data = pc, team


    with open('my_games.csv', 'w') as csvfile:
        fieldnames = ['pc', 'team','League', 'Gp', 'G','A','P','Pims']
        writer = csv.DictWriter(csvfile, fieldnames=fieldnames,delimiter= ":",
                                extrasaction ='ignore')
        i=0
        writer.writeheader()
        for pc in player_code:
            writer.writerow({'pc':[pc],'team':[team]})
            i+=1
</code></pre>

<p>This is only returning one line of data over and over. Any direction would be helpful! Thank you.</p>