Hi hally. I'm trying to work out why you used the do construct on line 27? Why is that needed as opposed to a bare block with no do? I understand that do can be used with while, or to overide the loop-like nature of bare blocks when used with next or last, neither of which is the case here.
Just a matter of style-- bare braces in the middle of nowhere make me itch, looking for an 'if' line that may have been deleted or obscured. Same reason I explicitly handle newlines and whitespace in two passes, though that's not really necessary.