read buffer until empty