implement basic stream write fn