import re
s='''new File()
new
File()
there is a new File()
new
    
    
    
File()
there is not a matching pattern here File() new
new File() test new File() occurs twice on this line
'''
pattern = r'new\s+File\s*\(\s*\)'
for m in re.finditer(pattern, s):
	linenums = [s[:m.start()].count('\n') + 1]
	for _ in range(m.group().count('\n')):
		linenums.append(linenums[-1] + 1)
	print('{} Found on line {}'.format(re.sub(r'\s+', ' ', m.group()), ", ".join(map(str,linenums))))