fix a bug in connect, should add encoding property when reading files