Strips trailing whitespace w/out moving the cursor

Integrates a function that keeps track of the cursor position.