Trying to get the write command to work in Python 3