fix #3 output stream does not preserve order of input stream