Fix max call stack size exceeded error when segment file does not exist or is empty.