The extension is irrelevant. The problem is you don't close the file after reading it. http://www.conitec.net/beta/afile_close.htm So when you start the function a secound time in level 2 the file is still open. If you don't need access to a file anymore always close it.