Make ReadStream and WriteStream generic in type written/read