Writes output to .csv