Don't attempt to connect when jni is not being used
use finish-output not force-output
only read-line when there are chars to read