try these changes...

Code:
if((file = fopen(filename,"rt")) == NULL)
{
	MessageBox(hwnd,"Couldn't load file!","Error",MB_OK | MB_ICONERROR);
						return;
}
fseek(file,0,SEEK_END);
length = ftell(filename);