I am not sure about the details of %attach that probably do something before interpreting the content of the file. A workaround is to use %load instead.