Adding outQueue
Implementing write and flush