parse and flatten a file