Update StreamIO.php

Added a check for a 'null' socket before writing.