Fixed returning 0 bytes written error