Better handling of exceptions in writer_thread
If an exception happened in writer_thread
then it was possible for the thread to exit, leaving the other threads waiting forever on a barrier. This change makes the thread with the exception continue the loop so that other threads can finish.