Refactor to make file reading injectable
Fixed error handling, now it reports the correct line on an error, also handles in-browser includes correctly