Sending pdf with Google email sheet


Attempting to send a PDF file attached to an email using Google sheets. I have checked and tried to use the answers in previous answers, but my code fails after sending the first email.
This is the code that I am using. Ignore the comments in the code. I'm trying to make things easier for others (like me) who try to swim against the current.
The error message I receive is that the following object can not be retrieved: the iterator has reached the end.
// This constant is written in column C for the rows for which an email
// has been sent successfully.
var EMAIL_SENT = & # 39; EMAIL_SENT & # 39 ;;

/ **
* Send unduplicated emails with data from the current spreadsheet.
* /
sendEmails2 () {function
var sheet = SpreadsheetApp.getActiveSheet ();
var startRow = 2; // First row of data to be processed.
var numRows = 3; // Number of rows to process Switch to the last line of DATA minus 1
// Get the range of cells A2: N4 Change to the last line of DATA minus 1
var dataRange = sheet.getRange (startRow, 1, numRows, 3);
// Fetch values ​​for each row in the range.
// The following line is added to try to find the pdf
var file = DriveApp.getFilesByName (& # 39; 2019 05 18 Update.pdf & # 39;)
var data = dataRange.getValues ​​();
for (var i = 0; i <data.length; ++ i) {
row row = data[i];
var emailAddress = row[0]; // fifth column
message var = row[1]; // Third column change header to message (or link to)
var emailSent = row[2]; // Column C
if (emailSent! = EMAIL_SENT) {// Prevent sending duplicates
var subject = & # 39; Update your HOA & # 39 ;;
// The following line is added to link the pdf to the email.
// MailApp.sendEmail (email address, subject, message, {attachments: file});
// ELIMINATED AND REPLACED WITH THE NEXT LINE MailApp.sendEmail (email address, subject, message);
MailApp.sendEmail (emailAddress, subject, message,
{attachments: file.next (). getBlob ()})
sheet.getRange (startRow + i, 3) .setValue (EMAIL_SENT);
// Make sure that the cell is updated immediately in case the script is interrupted
SpreadsheetApp.flush ();
}
}
}