private void doSave() {
        myFile = doRead();
        if (myFile == null){
            return;
        }
       
        String name = myFile.getName();
        showMessage("compressing " + name);
        String newName = JOptionPane.showInputDialog(this,
                "Name of compressed file", name + HUFF_SUFFIX);
        if (newName == null) {
            return;
        }
        String path = null;
        try {
            path = myFile.getCanonicalPath();
        } catch (IOException e) {
            showError("trouble with file canonicalizing");
            return;
        }
        int pos = path.lastIndexOf(name);
        newName = path.substring(0, pos) + newName;
        final File file = new File(newName);
        try {
            final FileOutputStream out = new FileOutputStream(file);
            ProgressMonitorInputStream  temp = null;
            if (myFast){
                temp = getMonitorableStream(getFastByteReader(myFile),"compressing bits...");
            }
            else {
                temp = getMonitorableStream(myFile,"compressing bits ...");
            }
            final ProgressMonitorInputStream pmis = temp; 
            final ProgressMonitor progress = pmis.getProgressMonitor();
            Thread fileWriterThread = new Thread() {
                public void run() {
                    try {
                    	while (! myFirstReadingDone){
                    		try {
								sleep(100);
							} catch (InterruptedException e) {
								// what to do?
								HuffViewer.this.showError("Trouble in Thread " + e);
							}
                    	}
                        myModel.compress(pmis, out, myForce);
                    } catch (IOException e) {
                        HuffViewer.this.showError("compression exception\n " + e);
                        cleanUp(file);
                        //e.printStackTrace();
                    }
                    if (progress.isCanceled()) {
                        HuffViewer.this.showError("compression cancelled");
                        cleanUp(file);
                    }
                }
            };
            fileWriterThread.start();
        } catch (FileNotFoundException e) {
            showError("could not open " + file.getName());
            e.printStackTrace();
        }
        myFile = null;
    }