It will create the file, if it can. fopen can't create a directory, for instance, so if there was no terrain subdirectory in your data directory already existing, then fopen will always fail (since...