fixed issue where fewer bytes are read from the socket than specified. files are now read in 4KiB chunks