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:
image

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):
        new_rows.append(row)

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

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

with open(new_file_path, 'wt') as fout:
    fout.write(lines)

return new_file_path

The question is already solved.