boundary check for read() & write()

read() logic check finished.
Next to check: write()