Changed it to write the data to file as chars instead of binary data