when opening a file for writing text, python3 re.

..quires specifying text mode and encoding