Improve efficiency for finding word frequency in text
You're right, the basic point to make this program faster is to store the line numbers in the first pass.

The for word in list loop will run many times. The count depends on how many words you have. Every time it runs, it reopens and rereads the whole input file. This is awfully slow.

If you start using a more generic data structure than your Counter(), then you'll be able to store the line numbers. For example you could use a dictionary. The key of the dict is the word, the value is a list of line numbers. The hit count is stored indirectly as the length of the list of line numbers.

In one pass over the input you can populate this data structure. In a second step, you can properly sort this data structure and iterate over the elements.

An example implementation:

from collections import defaultdict
import sys 

if __name__ == "__main__":
    hit = defaultdict(list)
    for lineno, line in enumerate(sys.stdin, start=1):
        for word in line.split():
            hit[word.lower()].append(lineno)
    for word, places in sorted(hit.iteritems(), key=lambda (w, p): (-len(p), w)):
        print len(places), word, ",".join(map(str, sorted(set(places))))


A few more notes:


If you open() a file, close() it too. As soon as you're done with using it. (Or use the with statement to ensure that it gets closed.)
Don't hardcode input/output file names. Read from standard input (sys.stdin), write to standard output (sys.stdout or simply print), and let the user use his shell's redirections: program &lt;input.txt &gt;output.txt
Don't litter standard output with progress messages. If you absolutely need them use sys.stderr.write or get acquainted with the logging module.
Don't use regular expressions, unless it's necessary. Prefer string methods for their simplicity and speed.
Name your variables in lower_case_with_underscores as PEP8 recommends.