Add write to csv method