how to replace a word in csv file using python

import csv

inputfile = csv.reader(open('civil-war-battles.csv','r'))
outputfile = open('placelist.txt','w')


for row in inputfile:
    place = row[2].replace(' ,',',')
    print place

Here is what the above code is Doing:
1. It’s opening the civil-war-battles.csv file and reading it into a variable called inputfile.
2. It’s opening a new file called placelist.txt and writing to it.
3. It’s looping through each row in the inputfile variable.
4. It’s taking the third element in each row (the place) and replacing any spaces followed by a comma with just a comma.
5. It’s printing the place to the screen.
6. It’s writing the place to the placelist.txt file.
7. It’s adding 1 to the variable i.