Adding a barrier so the output file is closed at an appropriate time.