PHP
$file = fopen("file.txt", "r");
while(!feof($file)){
$line = fgets($file);
# do same stuff with the $line
}
fclose($file);
Python 2
# Write a file
out_file = open("test.txt", "w")
out_file.write("This Text is going to out file\nLook at it and see!")
out_file.close()
# Read a file
in_file = open("test.txt", "r")
text = in_file.read()
in_file.close()
print text
Python 3
# Write a file
with open("test.txt", "wt") as out_file:
out_file.write("This Text is going to out file\nLook at it and see!")
# Read a file
with open("test.txt", "rt") as in_file:
text = in_file.read()
print(text)