TODO - use perlio (e.g. utf8 encoding) for reading files