Please look at this demo:

As you can see this script adds linebreak after each entry.

What I would like to do is have another button to undo each entry.

So let's say the content of the textarea is:

Entry one
Entry two
linebreak__________stops here
Entry three

We want the value of text area to always end with a linebreak so onclick it would get the value of textarea, start at the end and delete the last linebreak any text before it, stopping at the next linebreak.