Writing To CSV file Without Line Space in Python 3
Recommended implementation per Python3 Documentation.
with open('records.csv','w', newline='') as csvfile:
#creating a csv writer object
csvwriter = csv.writer(csvfile)
#writing the fields
csvwriter.writerow(fields)
# writing the data rows
csvwriter.writerows(rows)
https://docs.python.org/3/library/csv.html#csv.writer