Use safer file handling