List files with *.i extension in a directory and all its subdirectories + 30days old then remove

I need to write a script to :

list files with *.i extension in a directory and all its subdirectories + 30days old, save it in a file and then remove

Save what in a file? the output?

cd /path/to/main/directory
find /path/to/main/directory -type f -mtime +30 -name '*.i' |
while read fname
do
    echo $fname
    rm "$fname"
done > /tmp/output_file

It works. Thanks a lot.

Lena:)