inserting script into block and writing the file