using readtoend for buffering