I want to write to a file from a script that also includes functions. Everything seems to work, except that it writes nothing to the file (it writes "" to the file