only read one buffer for each read call, deallocate buffer after unwinding stack