JNI Wrapper: Close reader *and* writer at the end. Also, make close() call flush().
Pascal Wrapper: First commit.