I notice that the file you are reading is named
myfout.txt. The file apparently contains binary
Java objects, so the file should not have had the extension
.txt, because it is a not a plain text file.
Apparently the file contains a number of Customer objects, and you don't know how many there are, so you keep reading in a loop until you encounter an exception. That's indeed not really the best way to do it.
I don't know what the code looks like that writes this file, but it would have been better if this code just wrote an entire ArrayList of Customer objects at once, which you could then also load in one go.
To write the file:
To read the file: