atEnd method of the FileHandle class returns true after attempting to read past the end of the file.
atEnd is not true after the last successful read, nor is it true at the beginning of an empty file. It only reports the condition that the last attempted read failed because there was no more data. This is explained (in reference to the standard C function
reader = file.open("fileToRead.txt", "r") writer = file.open("fileToWrite.txt", "w") // Copy the lines from one to the other, while changing to upper case. while true line = reader.readLine if line == null then break writer.writeLine line.upper end while