You could try something like:
// Contain processed accnos to avoid processing duplicates
Initialise a "processedAccNos" array
// Store if we actually created an excel for the current accno
Initialise a "writtenToExcel" bool
// Set to your sale email once a match is found
Initialise a "recipient" string
Create a for each over topoffer
Conditional - is topoffer accno in "processdedAccNos"?
No:
Append topoffer accno to "processdedAccNos"
Set writtenToExcel to False
Set recipient to an empty string.
for each loop over salemaster.
Conditional on if the topoffer account number matches the salemaster account number
Yes:
Conditional writtenToExcel is True
No:
Create Excel
Set recipient to Sale email from salemaster item
Copy current record data from salemaster item to excel.
// Now our loop is finished, we can check if we just created an excel for the current topoffer accno.
Conditional is writtenToExcel true?
Yes:
Send the excel file to recipient.
The idea is to store a list of processed accno to avoid duplicates, and check for matches in salesmaster while iterating over your topoffer file. Then email the file once you've completed your checks. Make sure to name the excel file with the accountno and date, or something like that to avoid conflicts.