When writing the state file make sure to create the dir if it doesn't
exist