Used a with statement to deal with files