IO#write must write the encoded string when encoding is provided