Fix bug #9179 (New Untitled documents have wrong line endings on Windows)

Fix bug #9179 -- Use correct form of `Document.getText()` in Save As, like in Save. Plus unit test (had time to write one after all!).