String getFragment(int startPos, int endPos, String fileName) throws FileNotFoundException, IOException{
        String docFragment = "";
        RandomAccessFile doc = new RandomAccessFile(fileName, "r");
        int aByte = 0;
        
        doc.seek(startPos);
        if(startPos != 0){
            doc.seek(startPos - 1);
            aByte = doc.readByte();
            aByte = Character.toLowerCase(aByte);
            
            if(aByte >= 'a' && aByte <= 'z')
                while(aByte >= 'a' && aByte <= 'z' && startPos < endPos){
                    aByte = doc.readByte();
                    startPos++;
                }
        }
        while(startPos < endPos){
            aByte = doc.readByte();
            aByte = Character.toLowerCase(aByte);
            docFragment += (char)aByte;
            startPos++;
        }
        
         while(aByte >= 'a' && aByte <= 'z'){
            aByte = doc.readByte();
            aByte = Character.toLowerCase(aByte);
            docFragment += (char)aByte;
        }
         
        return docFragment;
    }