I realize that the csv library in Python always generates DOS end-of-line characters. Even if I use the \'wb\' mode, even if I use Linux.
\'wb\'
You can give your writer instance a custom lineterminator argument in the constructor:
writer = csv.writer(f, lineterminator="\n")