How to create feed and write that feed to a file

Creating RSS feed is easy and there are many articles on that.

However my requirement is to generate and write that feed as a file
(88.feed 89.feed etc). These feeds would be generated through cron every
night. Any idea how I can capture the output as a string.

U can do a curl and pipe it to a file

That's what I am doing right now. But that seem ugly. Was wondering if
there is a better way.

This is normally done using Rails page caching.