First of all … when you post code, error messages, console output or sample data please format it as code using the preformatted text button ( </> ). The picture you posted is almost unreadable.
Thanks in advance.
Is there a special reason why you’re not using Import-Csv and Export-Csv to deal with CSV files?