enough, it could be negative. Add i > 0 test. (Not i >= 0; zero isn't a valid error number.)
Attach a file by drag & drop or click to upload