ESP8266 sending blank attachments from SPIFFS over SMTP

I'm attempting to create a temperature/humidity monitor that logs temperature and humidity over time, saves it to a file in SPIFFS, and after x number of loops through, sends that file as a .csv attachment over SMTP. The environmental monitor works fine, and I can send emails just fine. However, when I receive the emails with the attachment (envmon.csv), it opens as blank. Does anyone have any idea as to why it won't send the data I've saved into the file? In another iteration of this code, I had it simply write the data from the file into an email, so I know the file is saving data correctly. As soon as I add it as an attachment, however, it's blank. My code is below (with passwords and such blanked out):

#include <ESP8266WiFi.h>
#include <DHT.h>
#include "FS.h"


const char* ssid = "xxxxxxxxxxx";   // Enter the namme of your WiFi Network.
const char* password = "xxxxxxxxxxx";  // Enter the Password of your WiFi Network.
char server[] = "xxxxxxxxxx.com";   // The SMTP Server

#define Type DHT11
int sensePin=D3;
int cycle=15;
DHT HT (sensePin, Type, cycle);

float tempF;
float tempC;
int humidity; 
int setTime=500;
int dt=1000;
int longDelay=3000; 
int fileSize;
int i=0; 
int port=25; 

WiFiClient espClient;       //declares WifiClient


void setup()

{

  Serial.begin(115200);  
    
  delay(10);
  Serial.println("");
  Serial.println("");
  Serial.print("Connecting To: ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  
  while (WiFi.status() != WL_CONNECTED)         //delay and print asterisks until WiFi is connected. Then prints IP address to serial monitor 
  {
    delay(setTime);
    Serial.print("*");
  }
  Serial.println("");
  Serial.println("WiFi Connected.");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());

HT.begin();

bool success = SPIFFS.begin(); 

if (success) {
  Serial.println("File system mounted successfully");
} else {
  Serial.println("Error mounting file system"); 
  return; 
}

SPIFFS.format();

File file = SPIFFS.open("/envmon.csv", "w"); 

if (!file){
   Serial.println("There was an error opening the file");
   return;
}

file.close(); 
}



byte sendEmailLog()            //declares sendEmail function and defines the function. 
{
  if (espClient.connect(server, port) == 1)
  {
    Serial.println(F("connected"));
  }
  else
  {
    Serial.println(F("connection failed"));
    return 0;
  }
  if (!emailResp())
    return 0;

  Serial.println(F("Sending EHLO"));
  espClient.println("EHLO www.example.com");
  if (!emailResp())
    return 0;

  Serial.println(F("Sending auth login"));
  espClient.println("AUTH LOGIN");
  if (!emailResp())
    return 0;


  Serial.println(F("Sending User"));


  espClient.println("xxxxxxxxx"); // Your encoded Username in ASCII format 
  if (!emailResp())
    return 0;


  Serial.println(F("Sending Password"));


  espClient.println("xxxxxxxxxxx");// Your encoded Password in ASCII format 
  if (!emailResp())
    return 0;

 

  Serial.println(F("Sending From"));

 

  espClient.println(F("MAIL From: xxxxx@xxx.com")); // Enter Sender Mail Id
  if (!emailResp())
    return 0;

  Serial.println(F("Sending To"));
  espClient.println(F("RCPT To: xxxx@xxx.com")); // Enter Receiver Mail Id
  //espClient.println(F("RCPT To: xxxxx@xxx.com")); //Enter second receiver ID and uncomment line, make sure to do so again below //
  if (!emailResp())

    return 0;

 

  Serial.println(F("Sending DATA"));
  espClient.println(F("DATA"));
  if (!emailResp())
    return 0;
  Serial.println(F("Sending email"));
  espClient.println(F("To:  xxxxx@xxx.com")); // Enter Receiver Mail Id. 
  espClient.println(F("To: xxxxxxxxx@xxx.com")); //Enter second receiver mail ID and uncomment line make sure to do so again above //
  espClient.println(F("From: xxxxxxx@xxx.com")); // Enter Sender Mail Id
  espClient.println(F("Subject: Environmental Monitor Log"));

  int espClientCountLog=0;  
  File fileToSend = SPIFFS.open("/envmon.csv", "r");

  espClient.println("MIME-Version: 1.0");
  espClient.println("Content-Type:multipart/mixed");
  espClient.println("Content-Type:application/ms-tnef;name = \"/envmon.csv\"");
  espClient.println("Content-Transfer-Encoding:base64");
  espClient.println("Content-Disposition:attachment;filename=\"/envmon.csv\"");

if(fileToSend) {
    while(fileToSend.available()){
      espClientCountLog = fileToSend.read(tBuf,64);
      espClient.write((byte*)tBuf, espClientCountLog);
    }
  fileToSend.close();
}

  else {
    Serial.println(F("File open failed!"));
  }


  espClient.println(F("."));
  if (!emailResp())
    return 0;

  Serial.println(F("Sending QUIT"));
  espClient.println(F("QUIT"));
  if (!emailResp())
    return 0;

  espClient.stop();
  Serial.println(F("disconnected"));
  return 1;

}

byte emailRespLog()

{
  byte responseCodeLog;
  byte readByteLog
  int loopCountLog = 0;

  while (!espClient.available())
  {
    delay(1);
    loopCountLog++;

    if (loopCountLog > 20000)
    {
      espClient.stop();
      Serial.println(F("\r\nTimeout"));
      return 0;
    }
  }

  responseCodeLog = espClient.peek();
  while (espClient.available())
  {
    readByteLog = espClient.read();
    Serial.write(readByteLog);

  }

  if (responseCodeLog >= '4')
  {
    return 0;
  }
  return 1;
}



void loop(){

                 //reads the temperature and humidity from the DHT11 sensor in Fahrenheit, Celsius and %
  delay (longDelay); 
  tempF = HT.readTemperature(true); 
  tempC = HT.readTemperature();
  delay (dt);
  humidity = HT.readHumidity(); 

  
  
if (isnan(humidity) || isnan(tempF) || isnan(tempC)) {
  Serial.println("Failed to read from DHT sensor!");
  return; 
  }


  
 File fileToAppend = SPIFFS.open("/envmon.csv", "a"); 
 if(!fileToAppend){
  Serial.println("There was an error opening the file");
  return; 
 }
 
fileToAppend.print(" , ");  
fileToAppend.print(tempF);
fileToAppend.print(" F , ");
fileToAppend.print(tempC);
fileToAppend.print(" C, ");
fileToAppend.print(humidity);
fileToAppend.println(" % "); 

fileToAppend.close();



i++;


  if (i>=10)
  {
  byte ret = sendEmailLog();
  SPIFFS.remove("/envmon.csv");
  i=0;
  }
delay (10000); 
}