writing with write instead of stdout