Use of reduce for word counting