Fixing error in output buffer