replace readline with read(16384) to avoid huge number of calls to server