The write function attempts to write the bytes specified by
the buf parameter to the open file descriptor fd. It
returns the number of bytes successfully written, or -1 and sets
errno upon failure. The number of bytes written may be less
than length(buf).