modified write

added returns to write statements to return successful write bytes