Make connection and write out data read in