E.g., with this input:
Get this output:
(1 3 4)
org-map-entries is a great function for this sort of thing:
(org-map-entries FUNC &optional MATCH SCOPE &rest SKIP)
Call FUNC at each headline selected by MATCH in SCOPE.
To do what you outlined above from within the target file it's simply a matter of:
(org-map-entries (lambda () (line-number-at-pos)) nil 'file)