use the ssize_t variable for read rather than ptrdiff_t