Use read/write functions of the stream to increase performance
p4#: 21698