Fix cat display error

Details:
2 problems here
1. read not always read buffer with expected size. ex: read 100 byte
   returned 80 bytes in first read
2. need if check return size is 0 for eof