# Charles Robison
# 2016.10.21
# File Lab

#!/usr/bin/env python
import os

cwd = os.getcwd()

# write a program which prints the full path to all files
# in the current directory, one per line
for item in os.listdir(cwd):
    print(cwd + "/" + item)

# write a program which copies a file from a source, to a
# destination (without using shutil, or the OS copy command)
file = open('file_lab01.txt', 'r')
file_text = file.read()
file_new = open('file_lab02.txt', 'w')
file_new.write(file_text)
file.close()
file_new.close()

# advanced: make it work for any size file: i.e. don’t read
# the entire contents of the file into memory at once.
file = open('file_lab01.txt', 'r')
file_new = open('file_lab02.txt', 'w')
file_text = file.readline()
for line in file_text:
    file_new.write(line)
    line = file.readline()
file.close()
file_new.close()

# not working correctl, second try:
print('second try:')

file_new = open('file_labe02.txt', 'w')
with open('file_lab01.txt', 'r') as f:
    for line in f:
        file_text = f.readline()
        file_new.write(line)
file_new.close()

@@ -634,22 +634,20 @@
 t once.%0A
-file =
+with
  open('f
@@ -665,255 +665,18 @@
 xt',
- 
 'r')
-%0Afile_new = open('file_lab02.txt', 'w')%0Afile_text = file.readline()%0Afor line in file_text:%0A    file_new.write(line)%0A    line = file.readline()%0Afile.close()%0Afile_new.close()%0A%0A# not working correctl, second try:%0Aprint('second try:')%0A%0Afile_new =
+ as r,
  ope
@@ -686,17 +686,16 @@
 file_lab
-e
 02.txt',
@@ -703,46 +703,13 @@
 'w')
-%0Awith open('file_lab01.txt', 'r')
  as 
-f
+w
 :%0A  
@@ -726,43 +726,10 @@
  in 
-f:%0A        file_text = f.readline()
+r:
 %0A   
@@ -733,23 +733,16 @@
         
-file_ne
 w.write(
@@ -747,23 +747,26 @@
 e(line)%0A
-file_ne
+r.close()%0A
 w.close(
@@ -759,16 +759,18 @@
 ose()%0Aw.close()%0A
+%0A%0A

Fix section to read and write large files.