Should be a space between while and (
IntelliJ handles all these - probably wise to run your code through it.
Checkout the Spark style guide https://cwiki.apache.org/confluence/display/SPARK/Spark+Code+Style+Guide