Changed write_file() to only create files in the parent path.