Convert document.lines to an array before sending back to the browser