added more sensible file io