Successfully writes all data to database and CSV output file