Bug fix for buffered stream