Detect line endings (Fixes #3)

The solution I'm using was posted by @harm-less in Issue #3 .

If @harm-less wants to submit this same pull request, I can withdraw mine so he gets credit for it.