Switch to using concat{} instead of lots of file{} magic.

Taken from #136 and rebased.

I removed the formatting changes to make things a bit easier to read. The specs currently fail because of existing issues with the specs - if PR #165 is pulled into master to fix the existing spec failures I'll rebase again, and all the tests should pass.