Fix the issue in the main_script to save csv correctly