How are you explicity separating the ID's in the file? newlines? any other character?
If you are writing the IDs with writeline, then you may recover them with a loop while(ID=filex.readline())
if you are using any other separator then you may read the whole file into a string and do a datareaded.split('x') where x is the separating character.
Or you can read byte after byte and comparing it against the separator to identify when a new ID is about to start.