Implemented word_wrap

Do let me know if there's a more idiomatic way to do this.
I would have expected a normal `if ... else` here, but maybe it is just a matter of taste