Checking for undefined filePath (fixing undefined error on first-time file save)