'Need to ignore lines and replace words in a csv python

i have to ignore some lines and replace some words in a csv, i tried using the following to replace but it looks like it gets ignored

if "myword" not in line:

to replace text i used

csv_writer.writerow(line.replace("oldword", "newword")) 

but this gets an error does someone knows why? EDIT WITH CODE

import csv

with open(r'excelfile.csv') as csv_file:
    csv_reader = csv.DictReader(csv_file)

    with open('new_names.csv', 'w', newline='') as new_file:
        fieldnames = ['value', 'type', 'description']
        writer=csv.writer(new_file)

        csv_writer =csv.DictWriter(new_file, fieldnames=fieldnames, delimiter= ',', extrasaction='ignore')

        csv_writer.writeheader()

        for line in csv_reader:
                csv_writer.writerow(line)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source