Updating wrong reference of streambuf