You are using
LaTeX (i guess
pdflatex) and not
LuaTeX which was used in the referred solution. Am I right?
Before You Start Your Thesis / Document
Following the LaTeX wikibook (link) about the internationalization in the case of Polish:
Polish has many single letter connectives [...] To ensure that LaTeX won't set them as last letter in
the line, you have to use non breakable space [...]
So the solution is to simply connect the following word with a ~ (tilde, also
known as a non breakable space).
The non breakable space feature of the tilde character is a core LaTeX feature (thanks at @DavidCarlisle).
By the way, I googled for polish single letter latex and the solution was the third entry in my hit list.
When You Have Already Finished Your Document
Maybe you can use a text editor like Notepad++ (https://notepad-plus-plus.org/) and search and replace
_w_ and so on with
_w~ and so on (with
_ I want to indicate a space).
Notepad++ also can search and replace in multiple files at once. Be sure that you try it on a backup copy of your actual document!
With regular expressions you may be able to have even more sophisticated ways. But I do not know much about that.