Fix an error with possible saving of file with empty filename.
Change script such that it now is configured with cli argument.