Added optional 3rd parameter: file extension