uses buffered stream