Problem with directory listings after other file IO