In the following example we read content of a file and print the result on the screen using a Python script.
The file that will be read from is file.txt:
The Python code for that is:
#!/usr/local/bin/python import sys file = open('file.txt') buffer = file.readlines() for line in buffer: print line.rstrip() # EOF.
Note: we will use rstrip() to remove end of line character for every line we print.