Seems to be working except that output file is missing values