If the purpose of checking the number of bytes written is to assert that the string was written out using the correct encoding, I think a better way might be to do as the spec immediately below, i.e. using `IO.binread`. Correct me if I'm wrong.