# Missing \begin{document} and undefined control sequence for a custom CV class

I am in the process of writing my own class for CV/Resume purposes, with the help of this website. However, when I compile cv.tex I get an error of undefined control sequence and also a missing \begin{document error}. Below I have included the code for cv.tex and my_cv.cls (the class file I am writing). I am unable to figure out what exactly has been causing these errors, but when I build into PDF, I get the desired output but with a blank page preceding it (the error messages do not go away).

cv.tex:

\documentclass{my_cv}

\begin{document}

\section{Education}
\datedsubsection{University of Blah}{2016--}

\section{Employment}
\subsection{Blah Blah}

\end{document}


my_cv.cls:

\NeedsTexFormat{LaTeX2e}
\ProvidesClass{my_cv}[2016/07/23]
\RequirePackage{titlesec}

\titleformat{\section}
{\Large\scshape\raggedright}
{}{0em}
{}
[\titlerule]

\titleformat{\subsection}
{\large\raggedright}
{}{0em}
{}

\newcommand{\datedsection}[2]{
\section[#1]{#1 \hfill #2}
}

\newcommand{\datedsubsection}[2]{
\subsection[#1]{#1 \hfill #2}
}


! Undefined control sequence.

\NeedsTeXFormat{LaTeX2e}

• (the difference is the X in TeXFormat that must be written with upper case. Took me a while to find it!) – ebosi Jul 24 '16 at 8:05