Fix a few warts in the frontend code
- Split getFilesDir and prerender_ demos into separate functions
- Fix a bug arising from lazy IO where writeFile and readFile got in each others' ways
- Fix a bug arising from trying to CHK encode empty strings
- Fix the Linux version of getFilesDir to create the directory if necessary