The problem isn't Python or Mac-specific. It's a question of text encoding.
When you open the input file, you specify that the encoding is UTF8. Therefore it's possible for the values you read to contain Unicode code points.
You don't specify the encoding you want to use for the output file. Apparently, the default is ASCII.
Because Unicode code points are a superset of ASCII, it is possible that your program will read some text that it can't write, and that is what the error indicates.
When you open the input file, you specify that the encoding is UTF8. Therefore it's possible for the values you read to contain Unicode code points.
You don't specify the encoding you want to use for the output file. Apparently, the default is ASCII.
Because Unicode code points are a superset of ASCII, it is possible that your program will read some text that it can't write, and that is what the error indicates.