If a large file(over a few GB) is loaded, error may appear. Try to use fopen64(). The fopen64() function is identical to the fopen() function except that the underlying file descriptor is created with the O_LARGEFILE flag set. The fopen64() function is a part of the large-file extensions.