Any ideas why this code won't work
<p>I have multiple files with names and stats and a file that checks for a certain stat.</p>

<pre><code>Example File 1
Eddy,23,2,4,9,AB
Frank,46,2,4,5,DA

Example File 2
AB
B
BA
DA
DH
</code></pre>

<p>I am not getting any errors but it is not writing to the new file.</p>

<p>The code I am using to do this is:</p>

<pre><code># Open Removal file and create a set of required removals
book_removals = open("File2.csv")
search_removals_col = 0

# Open the All Candidates file
book_candidates = open('File1.csv')
search_candidates_col = 4

# Create a New Roster file
book_new = open('upload.csv')

# Iterate through candidates file, looking for removals
for row in range(search_candidates_col):
if book_candidates == book_removals:
    book_new.write(row)
    book_new.flush
book_new.close()
</code></pre>

<pre><code>import csv
stats = set()
with open('File2.csv') as file2:
    for line in file2:
        stats.add(line)
with open('File1.csv', newline='') as file1:
    file1_reader = csv.reader(file1)
    with open('output.csv', 'w+', newline='') as output:
        output_writer = csv.writer(output)
        for line in file1_reader:
            if any(item in stats for item in line):
                 output_writer.writerow(line)
</code></pre>

<p>When dealing with .csv files, use the <code>csv</code> module.  This builds a <code>set</code> out of lines in <code>File2</code>, then goes through every line in <code>File1</code>.  If that line has a value from <code>File2</code>, then that line is written to <code>output.csv</code></p>

python python-3.5.2