How can I write something to textarea and clear it?

Yes, use \n for this. See also How to create Line breaks in a variable - #2 by admin

new line

Result: