Added check to see if options are available before using it in writeFile