More robust logging to CSV