Added checks before initializing the writer and added messages to the asserts