The 'remove trailing spaces from first field' logic backfired if the first field was all whitespace.
The logic to clear a:lines and replace it with the return of the function failed pretty miserably when the function returned a:lines. It cleared a:lines and then replaced it with the (now empty) elements.