spawn /bin/cat 
set run 0
#exp_internal 1
while 1 {
   incr run
   set lines_in {abc defg hijkl mnopqr stuvwxy}
   set lines_out ""
   foreach l $lines_in {
	send "$l\n"
    	expect {
		-re {\n} { lappend lines_out [string trim $expect_out(buffer)] }
		eof break
	}
    }
    if {$lines_in != $lines_out} break
}
puts "$run ============================="
foreach line $lines_out {
	puts "[string length $line] [string map {\r _ \n |} $line]"
}

