move creation of parameters file until after all datafiles have been created

this mitigates problems when datafile creation fails and there are dangling parameter.json files around
fixed invalid example in documentation