Not writing to sd card

Hello,

I am working on a small arduino project to read a temp sensor in a bee hive and record it on a sd card, Im currently just trying to create a file and save text, then adding on from there. I have done multiple of the examples from the SD library and they seem to work fine reading and writing to the sd card. I think i am just missing something small. Here is my code to look at.

thanks

#include <SPI.h>
#include <SD.h>

File myfile;
const int chipSelect = 10;

void setup() {
  
   Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
Serial.print("Initializing SD card...");

  if (!SD.begin(10)) {
    Serial.println("initialization failed!");
    while (1);
  }
  Serial.println("initialization done.");

  myfile = SD.open("hivemonitor.txt", FILE_WRITE);
  

  if (myfile) { 
    Serial.print("hello World");
    myfile.println("hello World");
    myfile.close();
    Serial.println("done");
  }
  else { Serial.println("error opening hivemonitor.txt");
  }

 

 



}

void loop() { }

timmerflyer:

  myfile = SD.open("hivemonitor.txt", FILE_WRITE);

From the SD library documentation:

It uses short 8.3 names for files.

What this means is the first part of the filename must be 8 characters or less, while the second part (file extension) must be 3 characters or less. The first part of your filename is 11 characters, which is why it's not working.