Catch out of range error but unsure if this is a good approach
Close file when finished