properly closing the connection if there are still bytes to be written
implemented escaping in the configuration file