There is already a method for writing the headers to the CSV file. No need to do this yourself.

[http://docs.python.org/2/library/csv.html#csv.DictWriter.writeheader](http://docs.python.org/2/library/csv.html#csv.DictWriter.writeheader)