If you are getting an exception, it is a good idea to share it with us. How are we to know what your code is doing?
I anticipate you are getting an OptionalDataException. If you look at the Java Documentation for ObjectInputStream:
Any attempt to read object data which exceeds the boundaries of the custom data written by the corresponding writeObject method will cause an OptionalDataException to be thrown with an eof field value of true.
Many people find that relying on an exception to signal an expected condition like EOF is counter-intuitive. The most common work-around is to either write the number of objects to the file then read only that number of times, or to put the objects in a collection and do a single read to load the collection and all the serialized objects (I prefer the latter).