implemented fallback writing to CSV file for manual processing if required