Added writing to CSV