Change the function NewFile to look like this: NewFile() { GetFileTime(); NewPage(); AddToTableOfContents(NEWFILE); FileLineNumber = 0; } And delete the call to the function NewPage() near the beginning of the function List().