Be less verbose and detect the end of the file (checking code and len).