python csv write add new line

with open('output.csv', 'w', newline='\n', encoding='utf-8') as f:
    writer = csv.writer(f)
    ...

Here is what the above code is Doing:
1. Opening a file called output.csv in write mode.
2. Creating a CSV writer object.
3. Writing the header row.
4. Writing the data rows.
5. Closing the file.