Hashcheck filewriter

Implement hashchecking for the filewirter, compatible with the reader. Also change system.out'ing of errors to throwing exceptions.