Improved disposal management and error handling in Read and Write methods