Add missing newline characters to fputs calls
Fix minor style nit
Factor out mime type identification
Hide the ugly helper functions in a tools module
Send selected files to client

While here fix a whitespace error.
Fail if request can't be read