Fix trailing newlines in prompt corrupt history

.julia_history stores the prompt text with leading tab indentation, and the
REPL expects all prompt lines to start with a `\t`. Previously, these tabs were
inserted when writing to the history file by substituting line starts (r"^"ms)
with a tab character. However, final newlines are not considered line starts,
so they were entered into the history file without the tab, which corrupts the
file.

This fixes that, by prefixing the prompt with a `\t` and then replacing all
newlines with `\n\t`.
Merge pull request #7164 from mbauman/repl-trailing-newlines

Trailing newlines in prompt corrupt the history file