id4: handle end of stream correctly. closes #27