Check deserialized object for null before using it.
Close BufferedReader and InputStreams to prevent resource leaking.
Remove unnecessary code to wait in main().