Add a common function for reading template files