Should probably read one less than bufsize, otherwise there is no room for the terminating zero.