updated block write with filename control