Writing my infile changes to an outfile : I wrote the following code:

    import sys, csv, operator
    data = csv.reader(open('books.csv'),delimiter=',')
    header = next(data)
    print (header)
    sortedlist = sorted(data, key=operator.itemgetter(1))
    with open("books_sort.csv", "wb") as f:
    #          fileWriter = csv.writer(f, delimiter=',')
               fileWriter = csv.writer(f)
    #           fileWriter.writerows(header)
    #           fileWriter.writerows(sortedlist)
    
               for row in sortedlist:
                  print (row)
    #             f.writerows(row)

The objective of this code is to take a file with contents in columns and alphabetize the file based on the second column only. It then outputs the desired result in a new file. My code above can print the desired reult but when I try to make it output a new file containing it, it does not work. You can see above in the comments for the parts where I tried to write a new file. Do guys have any ideas on how to do this? Before any of you say that an easier way would be to use pandas, I am specifically not allowed to do so. The following is the contents of my file:

    Title,            Author,        Publisher,  Year,  ISBN-10,   ISBN-13
    Automate the...,  Al Sweigart,   No Sta...,  2015,  15932...,  978-15932...
    Dive into Py...,  Mark Pilgr..., Apress,     2009,  14302...,  978-14302...
    "Python Cook...,  "David Bea..., O'Reil...,  2013,  14493...,  978-14493...
    Think Python...,  Allen B. D..., O'Reil...,  2015,  14919...,  978-14919...
    "Fluent Pyth...,  Luciano Ra..., O'Reil...,  2015,  14919...,  978-14919...