Updated  to automatically close itself when its iterator is empty.
Updated ProtocolBufferWriter to extend OutputStream.