Yes, since I wasn't sure of your requirements, I added the qualifier when I posted the pattern. Now I see that @drdrang's RegEx pattern is the best for your requirements.
With that said, it never hurts to contribute alternatives since others may see this post in the future and have the need to remove trailing whitespace AND remove all whitespace-only lines.
FYI, I recently shared a macro that is pertinent to this topic: Text Transformation EXAMPLES
(*I'm a relatively old chemical/process automation engineer and through the many years we often had to do complex transformations particularly when were were moving a configuration from one control system to another. For the really fun stuff, we used awk, first on HP-UX, later on macOS, and then finally on Windows. Oddly enough, there was a third-party awk compiler available on Windows. It was very good.)
I've added @ComplexPoint's JXA method to the example macro. It will be included with the next update.
Finally, I'd like to point out that there is one subtle difference between @drdrang's RegEx and @ComplexPoint's JXA. The former does not remove leading and trailing whitespace-only lines.