Fix multiple regressions in file writer and syntax check:

* One too many trailing new lines written to file
* Removing last line in files that do not have trailing new lines (IXS
does have files like that)
* Incorrectly reporting syntax errors in files lacking trailing new
lines

Also:
* Fix some ReferenceErrors
* New parameter for _syntaxChecks(): levelLayout
* _syntaxChecks() returns layout suitable for writing if all checks
passed