I would really prefer to use the existing line separator. Users might configure their line end characters to be Unix even on Windows. My order of preference is: end of line character of the previous line (if it exists), otherwise the platform preference. You can use:

```
document.getLineDelimiter(document.getLineOfOffset(offset))
```

(not sure how well this works if this is on the first line of the document)