Why do empty spaces cause syntax error?

I always use an external editor such as Atom or VSCode with lua extensions. They show pretty quickly if there is something fishy about your code and you can clean up whitespace stuff. The only annoying thing is that you need to save your script in a lua file before the external editor can open it.
You can configure the external editor in options. Now when you click the edit button it will open the external editor instead of the annoying built in. I guess the build in is really just for glimpsing at a script or making a quick change.