Database error log

This pull request achieves the goal of making the output of `database.hs` easier to read.

I was getting annoyed with not knowing when database insertion would complete, so I decided to sort the directory contents before working on them.
Done.