Ed command execution in script file

     
        for file in File_Name*
        do
                ed -s $file << 'EOF'
                0a
                $Header_Record
                .
                $a
                .
                w
                EOF
        done

The above command is executing in the unix box but is not when I write it in script file.

Is there another format for this?

Remove the spaces/tabs before the last delimiting identifier EOF, something like this:

 for file in File_Name*
        do
                ed -s $file <<EOF
                .
                .
                .
                .
EOF
        done

Alternatively, you can use the <<- redirection operator, which allows leading tabs (not spaces, tabs only).

Franklin52's suggestion is more robust, but I mention this alternative for the indentation-obsessed (such as myself).

Regards,
Alister