Add maxNumberOfLines
Pass maxNumberOfLines, remove the extra created flags. Pass the same instance of exitFlag