Blank lines in output

Hello all,

I’m wondering copying the first column in csv data to other columns. I write some code and it works well in python environment (I use Spyder), but not good in “GH Python Script Editor”, which will create an additional blank row for every data. Just like this:

Can anyone help me with the issue?

Here is my code:

def copy_csv_column(csv_path, run_hours):
with open(csv_path, ‘r’) as f:
reader = csv.reader(f)
rows = [row for row in reader if row]

for i in range(len(rows)):
    for j in range(int(run_hours)-1):
        rows[i].insert(j+1, rows[i][0])

new_file_path = csv_path.split(".csv")[0] + "_modified.csv"
new_rows = []
for row in rows:
    if any(field.strip() for field in row):

with open(new_file_path, 'w') as f:
    writer = csv.writer(f)

with open(new_file_path,'rt')as fin:
    for line in fin:
        if line!='\n':

with open(new_file_path, 'wt') as fout:

return new_file_path

The question is already solved.