using with construct

using with construct so that the file closes smoothly