If the rightmost character was a space, it must also be changedto a blank char. I admit this is a bit of a stretch.
Removed unused array
Removed unused array
Any character that is not space, underscore, empty char, or space represents the edge of the grid