'Writes the given `text` to the file.'

def write_text(self, text, encoding='utf-8', **kwargs):

    if isinstance(text, bytes):
        text = text.decode(encoding)
    with open(self, 'w', encoding=encoding, **kwargs) as f:
        f.write(text)
