ftell() returns the position of the file stream. In this case (since you just opened the file), it will return zero. if(0 == NULL) is evaluating to true, so your program is exiting.