correct file_put_contents() syntax

* explicitly add a `TRUE` check to file exist check
* switch the `file_put_contents()` arguments to be the right way around
fix indent; add wspace to sql