Whenever the file ends with newline, the builtin previewer was adding an
empty line at the end of the file. That's a side effect splitting and
rejoining the lines with \n. Basically, when we split a\nb\nc\n we get
{'a', 'b', 'c', ''}, then nvim_buf_set_lines treats each item in the
table as a line, and inserts an empty line at the end.
We do need to account for files that don't end with a new line though,
hence the check.
I don't have a way to test the \r\n logic locally, no Windows hosts
around, but it should work too.