fix a memory allocation bug in loadFile