public TheDocument(String htmlFile) {
	    
		    file = new File(htmlFile);
    		isWrapped = false;
    		isIndented = true;
    		isSaved = true;
    		setFilepath(htmlFile);
    		reader = new DocumentReader();
    		care = new DocCaretaker();
    		
    		
    		if(!file.exists()){
                try {
                    domDoc = reader.newDocument(file);
                } catch (IOException e) {
                    System.out.println("Cannot create new file.");
                } catch (ParserConfigurationException e) {
                    // TODO Auto-generated catch block
                    isWellFormed = false;
                    e.printStackTrace();
                }
            }
    		else{
    		//Testing stream
        		try{
            		domDoc = reader.buildDocument(file);
            		tree = reader.buildTree(domDoc);
        		}catch(Exception e){
        		    this.isWellFormed = false;
        		}
    		}
    		
    		FileInputStream stream = null;
    		MappedByteBuffer bb = null;
    		try {
    		     stream = new FileInputStream(file);
    		  
    		    FileChannel fc = stream.getChannel();
    		    bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
    		    if(this.isWellFormed()){
    		        xml = reader.parseAndPretty(Charset.defaultCharset().decode(bb).toString(),"2");
    		    }
    		    else{
    		        xml = Charset.defaultCharset().decode(bb).toString();
    		    }
    		  } catch (IOException e) {
                e.printStackTrace();
    		  } 
    		  catch (Exception e){
                isWellFormed = false;
    		  }
    		  finally {
    		    try {
                    stream.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
    		  }		
    		  
    		  this.createMomento();
    		  care.storeState(momento);
	}