File opening error detection added