Read input from redirected stdin with python
As others have mentioned, probably your condition line == '\n'
never holds true. The proper solution would be to use a loop like:
for line in sys.stdin:
stripped = line.strip()
if not stripped: break
lines.append(stripped)
Consider the following option
import sys
sys.stdin = open("input.txt", "r")