Fix NPE when using local directory for out file