reading and writing streams of data