Fixed issue where last word of sentence wouldn't be synonymized. Divided
script into several functions.