You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: writeBDL.m
    path of file: ./repos/gptoolbox/mesh
    
    the code of the file until where you have to start completion: function writeBDL(filename,V,F)
  % WRITEBDL Write a mesh to a .bdl file
  % 
  % writeBDL(filename,V,F)
  %
  % Inputs:
  %   filename  path to .bdl file
  %   V  #V by dim list of mesh vertices
  %   F  #F by 3 list of triangle indices

  function headerStart = writeBDLChunkHeader(fp, chunktype, nBytes)
  % writes chunk header into file stream
  %
  % Usage:
  %   headerStart = writeChunkHeader( fp, chunktype, nBytes )
    switch chunktype
        case 'MESH_CHUNK'
            magicID = 1;
        case 'MESH_GROUP'

    
function writeBDL(filename,V,F)
  % WRITEBDL Write a mesh to a .bdl file
  % 
  % writeBDL(filename,V,F)
  %
  % Inputs:
  %   filename  path to .bdl file
  %   V  #V by dim list of mesh vertices
  %   F  #F by 3 list of triangle indices

  function headerStart = writeBDLChunkHeader(fp, chunktype, nBytes)
  % writes chunk header into file stream
  %
  % Usage:
  %   headerStart = writeChunkHeader( fp, chunktype, nBytes )
    switch chunktype
        case 'MESH_CHUNK'
            magicID = 1;
        case 'MESH_GROUP'
            magicID = 2;
        otherwise
            magicID = 0;
    end