diff --git a/debpython/pydist.py b/debpython/pydist.py
index 6bb8a2e75c3a170895cc6d915d51212599852fd6..e1fcdd0a190b8165684336f285fc8e0bcc1736b8 100644
--- a/debpython/pydist.py
+++ b/debpython/pydist.py
@@ -118,8 +118,7 @@ def guess_dependency(req, version=None):
                  'or your upstream author to fix requires.txt')
         return set()  # should we sys.exit(1) here?
     req_dict = req_dict.groupdict()
-    name = req_dict['name'].lower()
-    details = data.get(name)
+    details = data.get(req_dict['name'].lower())
     if details:
         for item in details:
             if version not in item.get('versions', version):
@@ -157,7 +156,9 @@ def guess_dependency(req, version=None):
         exit(8)
 
     result = set()
-    for line in stdout:
+    for line in stdout.split('\n'):
+        if not line.strip():
+            continue
         result.add(line.split(':')[0])
     if len(result) > 1:
         log.error('more than one package name found for %s dist', name)
diff --git a/pyclean b/pyclean
index c13fcb1ff648330d28a7ff0267e5c572e166f801..f21126242d4e8f9c2603100a1b70a0e86e262e1e 100755
--- a/pyclean
+++ b/pyclean
@@ -91,8 +91,7 @@ def get_package_files(package_name):
     if process.returncode != 0:
         log.error('cannot get content of %s', package_name)
         sys.exit(2)
-    for line in stdout:
-        line = line.strip('\n')
+    for line in stdout.split('\n'):
         if line.endswith('.py'):
             yield line
 
diff --git a/pycompile b/pycompile
index ba618cf1ef59c15cb2431e5dd2487bea384f0d6e..976aa28dde2341a2628485238a11fd6d4bf2db2e 100755
--- a/pycompile
+++ b/pycompile
@@ -26,8 +26,8 @@ from __future__ import with_statement
 import logging
 import optparse
 import sys
-from os import environ, listdir, mkdir, walk
-from os.path import abspath, dirname, exists, isdir, isfile, join
+from os import environ, listdir, walk
+from os.path import abspath, exists, isdir, isfile, join
 from subprocess import PIPE, Popen
 sys.path.insert(1, '/usr/share/python/')
 from debpython.version import SUPPORTED, debsorted, vrepr, \
@@ -74,8 +74,7 @@ def get_package_files(package_name):
     if process.returncode != 0:
         log.error('cannot get content of %s', package_name)
         exit(2)
-    for line in stdout:
-        line = line.strip('\n')
+    for line in stdout.split('\n'):
         if line.endswith('.py'):
             yield line