Initialize isDirectory = false when creating the file, and create the directory in writeFile
Also chalk task errors