Don't try and call fileno on a NULL fp.
Reformatting, remove unused UNKNOWN mode.
Add unquote.