public void writeRouteToFile() {
        int[] order = routeFinder.getBestOrder();

        if(order.length == 0) return;
        
        routeFinder.setLengthMatrix(Helper.createLengthMatrix(subRouteMatrix));
        
        int length = routeFinder.getRouteLength(order);
        
        SimpleDateFormat df = new SimpleDateFormat("MM.dd.yyyy HH.mm.ss");
        String time = df.format(java.util.Calendar.getInstance().getTime());
        
        String outFile = "action " + length + " " + time + ".txt"; 
        
        try (BufferedWriter writer = new BufferedWriter(new FileWriter(outFile))) {
            
            writer.write(length + order.length - 2 + ";");
            writer.newLine();

            // No start point for Grand Challenge!
//            writer.write(
//                    maze.getStartPoint().getX() + ","
//                    + maze.getStartPoint().getY() + ";");
//            writer.newLine();
            
            Venue[] ptv = maze.getVenues();
            
            for(int i = 0; i < order.length - 1; i++) {
                int from = order[i], to = order[i+1];
                
                if (i != 0) {
                    writer.write("take product #" + ptv[from-1].getId() + ";");
                    writer.newLine();
                }
                
                writeSubRoute(writer,
                        subRouteMatrix[from][to].getPath(from > to));
            }
            
            Helper.log("Route saved to " + outFile);
            
            writer.close();
        } catch (IOException e) {
            Helper.error("Not able to write to file");
        } catch (InvalidRouteException e) {
            Helper.error("Route invalid!");
        }
    }