Make line ending check and insertion workable for Windows systems

On Windows a line ending is `\r\n` and not only `\n`.

This also fixes warnings about missing parenthesis at side-effecting
methods.
Fix bug in AutoIndentStrategy when the tab key is pressed in the first line