Make line endings consistent when inserting text.

Editors like VIM are able to detect whether a file is Dos/Windows or
Unix, but if the line endings are inconsistent, it won't know what to
do, and ends up showing "^M" in the place of a carriage return. So this
new code will detect what line endings are currently being used in the
file and ensure that any lines inserted end with the same line ending.
Merge remote-tracking branch 'origin/master' into Further-project-model-changes