Fixed coredump on EOF