From this question, this ...
lines = foo.value.split(/\\r\\n|\\r|\\n/);
is one way to split a string, but how do I join it back with newlin
You can use the Array object's join method to glue together array elements into a string:
Array
lines.join("\r\n");
In CSS: remember to use
white-space: pre;