Added writing to file and column headers