Redmine #1032 - makes readfile() more generic

Follow-up of https://github.com/cfengine/core/pull/1026