Correct handling for iterable as return value.
Synchronized output to writer