Writing to file now works after the queue is empty