public void SaveMarkers() {  // saves a marker-file and generates a new set of marker list from it
      try {
        System.out.println("Saving marker file: "+markerOutfilename);
	FileOutputStream os=new FileOutputStream(markerOutfilename);

	if (AppendVersionNumber)  // to advance the number
	  {
		markerInfilename = markerOutfilename; // copies the old name
		  int nBeg=markerOutfilename.length()-1,nEnd=markerOutfilename.length(),Num=1;
		  String MyNumber;
		  // ist the last digit a number?
		  try{
		  while(nBeg >= 0) // look for the longest number before the ".txt" ending
			  { 
    		    MyNumber=markerOutfilename.substring(nBeg,nEnd);
                //System.out.println("Substring:"+MyNumber+"\n");
		  	    Num=Integer.parseInt(MyNumber);
		  	    nBeg--;
		  	  }}
		  catch (Exception e)
		      {}
		  if (nBeg == nEnd-1)  // last digit was not a number
		  {
			  nBeg -= 4; // skip the last three digits and try again:
			  nEnd -= 4;
			  try{
				  while(nBeg >= 0) // look for the longest number before the ".txt" ending
					  { MyNumber=markerOutfilename.substring(nBeg,nEnd);
		                //System.out.println("early Substring:"+MyNumber+"\n");
				  	    Num=Integer.parseInt(MyNumber);
				  	    nBeg--;
				  	  }}
				  catch (Exception e)
				      {}
		  }
          NumberFormat  nf = java.text.NumberFormat.getIntegerInstance(Locale.US);
          nf.setMinimumIntegerDigits(nEnd-nBeg-1);
          markerOutfilename=markerOutfilename.substring(0,nBeg+1)+nf.format(Num+1) + markerOutfilename.substring(nEnd,markerOutfilename.length());
	  }

	  Writer out = new BufferedWriter(new OutputStreamWriter(os));
	out.write(GetMarkerPrintout(this));
	out.close();
        os.close();
	}
        catch(IOException e)
            {
                System.out.println("saving markers, IOException:"+e);
                e.printStackTrace();
            }
        catch(Exception e)
            {
                System.out.println("saving markers, Memoryexception! "+e + "\n");
                e.printStackTrace();
            }

    }