pep8ified code, simplified code: use open(..).readlines instead of pipe open