Fix spacing
Create write function which returns amount written and only tries to write once
Try using new write function one way but get Segmentation Fault
Fix return type to int, still Segmentation fault