Move main parts to functions so it can be imported.
Merge branch 'master' of https://github.com/hugovk/word-tools