fixed writing output file in the correct (i.e writable part of the filesystem).