Implemented save operation for document.