seek( call is used here before each test to rewind the file to its beginning (more on this call in moment)file seek( file read('hello file world!\nbye file world \nfile seek( file readlines(['hello file world!\ ''bye file seek( file readline('hello file world!\nfile readline('bye file world \nfile readline('file seek( file read( )file read( (' ''ello fil'go back to the front of file read entire file into string read entire file into lines list file world \ 'read one line at time empty string at end-of-file read (or remainingchars/bytes empty string at end-of-file all of these input methods let us be specific about how much to fetch here are few rules of thumb about which to chooseread(and readlines(load the entire file into memory all at once that makes them handy for grabbing file' contents with as little code as possible it also makes them generally fastbut costly in terms of memory for huge files--loading multigigabyte file into memory is not generally good thing to do (and might not be possible at all on given computeron the other handbecause the readline(and read(ncalls fetch just part of the file (the next line or -character-or-byte block)they are safer for potentially big files but bit less convenient and sometimes slower both return an empty string when they reach end-of-file if speed matters and your files aren' hugeread or readlines may be generally better choice see also the discussion of the newer file iterators in the next section as we'll seeiterators combine the convenience of readlines(with the space efficiency of read line(and are the preferred way to read text files by lines today the seek( call used repeatedly here means "go back to the start of the file in our exampleit is an alternative to reopening the file each time in filesall read and write operations take place at the current positionfiles normally start at offset when opened and advance as data is transferred the seek call simply lets us move to new position for the next transfer operation more on this method later when we explore random access files file and directory tools