changed output to use csvwriter.