Fixed get file by index method