I would like to add the line number of each line instead of the character "a" which I managed to add by tweaking the code a bit.
The code is already modified according to How to continue lines on next page in exam class \fillwithlines in order for the lines to span over multiple pages.
Here is the code at the moment:
\makeatletter
\newlength\linefillheight
\newlength\linefillthickness
\setlength\linefillheight{.25in}
\setlength\linefillthickness{0.1pt}
\newcommand{\linefill}[1]{\leavevmode
#1 \leaders\hrule height \linefillthickness \hfill\kern\z@}
\def\fillwithlines#1{%
\begingroup
\ifhmode
\par
\fi
\hrule height \z@
\nobreak
\setbox0=\hbox to \hsize{\hskip \@totalleftmargin
\vrule height \linefillheight depth \z@ width \z@
\linefill{a}}%
% We use \cleaders (rather than \leaders) so that a given
% vertical space will always produce the same number of lines
% no matter where on the page it happens to start:
%\cleaders \copy0 \vskip #1 \hbox{}%
\loop\ifdim\dimen0<#1\relax
\advance\dimen0 by \ht0
\copy0\space
\repeat
\endgroup
}
\makeatother