Fixing stream error