Add a method to close files
Add preconditions checks to ensure that the writer or reader has not closed the stream before doing any operations