- $result = fputs($this->_fd, $data);
- if ($result === FALSE) {
- throw new Exception('Unable to write data: ' . substr($data, 0, 20));
+ $result = fwrite($this->fd, $data);
+ if ($result === FALSE || $result != strlen($data)) {
+ throw new \Exception('Unable to write data: ' . substr($data, 0, 20));