with can be used to automatically close a filewith statement can be used with all context
manager typeswith always closes the file, even when exceptions are
raisedWrite the first 1000 positive integers to a file
Read the values from that file one at a time and write their squares to a second file
with statement can be used to automatically close
files