I think we can simplify this further by making writeData() take the stream. Let me attempt in follow-up 'cause it's awkward to explain.