fixed get_word edge cases

Specifically, a word at the beginning or end of a file would not return the correct region.