cleaned read/write output
used portable int types for pointers