If you want to write to a user who is logged in more than once, you can choose a particular terminal with ttyname. (This misfeature is deprecated.) Otherwise write will choose a terminal for you.
The other user can use mesg to allow or deny write permission. In many recent versions of write, you cannot write to a user unless you are also allowing messages. Unfortunately, this adds absolutely no security, because you can turn messages right back off after starting write. This clone version exhibits the right behavior: it checks mesg permission on the other end before writing each line.
This version of write does not allow shell escapes.
There are many popular ways of using write (perhaps the most common being to use talk instead). Typically each user ends each series of lines with a distinctive signal, such as ``ga'' (go ahead), so that the other user can type without worrying about messed-up output. The number of abbreviations used in screen conversation is immense. See talkacros(7) for further information.
This clone version of write uses the standard input, rather than the standard error, to determine your tty.
write displays control characters in a printable form.
write sleeps for a second after sending each line. This restriction means that you can't flood someone else's screen with a large text.