Cleaned up several Python issues,
such as:
- using spaces for indent instead of tabs,
- changed the filename to a .py, instead of .sh
Also:
- added check for EOF in case you are piping input from STDIN
- changed the looping boolean logic to be more clear