public static void main( String[] args )
    {
        try
        {
            Scanner s = null;
            BufferedWriter b = null;
            String st = "";
            int numThreads = 8;
            for( int i = 1; i <= numThreads; i++ )
            {
                s = new Scanner( new File( "0.txt" ) );
                b = new BufferedWriter( new FileWriter( "" + i + ".g") );
                while( s.hasNextLine() )
                {
                    st = s.nextLine();
                    if( st.equals( "numThreads := 1;" ) )
                    {
                        b.write("numThreads := " + numThreads + ";" );
                        b.newLine();
                    }
                    else if( st.equals( "threadId := 1;" ) )
                    {
                        b.write("threadId := " + i + ";" );
                        b.newLine();
                    }
                    else
                    {
                        b.write(st);
                        b.newLine();
                    }
                }
                s.close();
                b.close();
            }
        }
        catch( Exception e )
        {
            e.printStackTrace();
        }
    }