This will run top once write the output to a file and exit. The command top can also be run so that it will give multiple reports.
top -b -n1 > /tmp/top.txt
To run top 5 times and wait 5 seconds between each output the command would be:
top -b -n5 -d5 > /tmp/top.txt