Implementing tail command in python