Listing 10. Modifying Standard Input

#! /usr/local/bin/python
import sys
while 1:
    data = sys.stdin.readline()
    if data != '':
        # do some processing of the contents of
        # the data variable
        data = '#'+data
        # end of data processing module
        sys.stdout.write(data)
    else:
        sys.stdout.flush()
        break