use read(-1) instead of readall()