4877: don't delete /dev/stdout

Fixed the filename check before trying to delete /dev/stdout.
Merge branch '4877-dont-delete-stdout'

Fixes #4877