Hey Sam!
The runscript is what gets executed after the container is built, so the environment variable `$SINGULARITY_ROOTFS` is long gone (it's only relevant in a build specification file in the %setup section at build time). So if you want to write an output file, if you direct it somewhere in the container you will get an error (the container is read only!) Instead, try binding a directory that you have write access for to the container, eg:
singularity run --bind /path/with/write:/opt container.simg
and then in the runscript, make sure to write your result to whatever that directory is (in the above example, /opt)
%runscript
./binary | tee /opt/resultsfile
Most default installations will bind /tmp automatically where you would have write, so you could also skip the bind and write there. If you want more specific details or help, please share your recipe and the output that you are getting, and we can go from there!
Best,
Vanessa